Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(529)

Issue 217400043: code review 217400043: compiler: Accept map literals with omitted key type.

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years ago by cmang
Modified:
8 years, 11 months ago
Reviewers:
iant
CC:
gofrontend-dev_googlegroups.com
Visibility:
Public.

Description

compiler: Accept map literals with omitted key type. Fixes golang/go#10263.

Patch Set 1 #

Patch Set 2 : diff -r 0def388e2919 https://code.google.com/p/gofrontend #

Patch Set 3 : diff -r 0def388e2919 https://code.google.com/p/gofrontend #

Total comments: 1

Patch Set 4 : diff -r 46a450318709 https://code.google.com/p/gofrontend #

Total comments: 1

Patch Set 5 : diff -r 46a450318709 https://code.google.com/p/gofrontend #

Patch Set 6 : diff -r 46a450318709 https://code.google.com/p/gofrontend #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+101 lines, -65 lines) Patch
M go/expressions.h View 3 chunks +80 lines, -0 lines 0 comments Download
M go/expressions.cc View 2 chunks +14 lines, -63 lines 1 comment Download
M go/parse.cc View 1 chunk +7 lines, -2 lines 0 comments Download

Messages

Total messages: 6
cmang
Hello iant@golang.org (cc: gofrontend-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/gofrontend
9 years ago (2015-03-27 00:05:25 UTC) #1
iant
https://codereview.appspot.com/217400043/diff/40001/go/parse.cc File go/parse.cc (right): https://codereview.appspot.com/217400043/diff/40001/go/parse.cc#newcode2708 go/parse.cc:2708: type->map_type()->key_type()->named_type()->name(); This doesn't work. You're assuming that the map's ...
9 years ago (2015-03-27 21:30:58 UTC) #2
cmang
On 2015/03/27 21:30:58, iant wrote: > https://codereview.appspot.com/217400043/diff/40001/go/parse.cc > File go/parse.cc (right): > > https://codereview.appspot.com/217400043/diff/40001/go/parse.cc#newcode2708 > ...
8 years, 11 months ago (2015-04-07 20:20:47 UTC) #3
iant
https://codereview.appspot.com/217400043/diff/60001/go/parse.cc File go/parse.cc (right): https://codereview.appspot.com/217400043/diff/60001/go/parse.cc#newcode2718 go/parse.cc:2718: && type->map_type() != NULL) Unfortunately, you can't call type->map_type() ...
8 years, 11 months ago (2015-04-07 20:56:32 UTC) #4
cmang
On 2015/04/07 20:56:32, iant wrote: > https://codereview.appspot.com/217400043/diff/60001/go/parse.cc > File go/parse.cc (right): > > https://codereview.appspot.com/217400043/diff/60001/go/parse.cc#newcode2718 > ...
8 years, 11 months ago (2015-04-08 19:45:26 UTC) #5
iant
8 years, 11 months ago (2015-04-08 22:22:57 UTC) #6
https://codereview.appspot.com/217400043/diff/100001/go/expressions.cc
File go/expressions.cc (right):

https://codereview.appspot.com/217400043/diff/100001/go/expressions.cc#newcod...
go/expressions.cc:12454: this->type_ = this->type_->map_type()->key_type();
Now that I look at the code I don't see how it will work for a composite literal
in which the map key type is omitted at a depth other than 0.

type S struct { s [1]*M }
type M map[S]int
var V = M{{s:[1]*M{&M{{}:1}}}:2}

Somehow we have to know, as we walk through depth, whether to use
map_type()->val_type() or map_type()->key_type().  As far as I can see the
choice at any depth is arbitrary.  Maybe we have to change from a single integer
to a vector<bool>, where each entry is false for the normal case and true if we
should use map_type()->key_type().
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b