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

Issue 4271061: code review 4271061: go/parser: resolve identifiers properly (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 11 months ago by gri
Modified:
13 years, 11 months ago
Reviewers:
CC:
rsc, rog, golang-dev
Visibility:
Public.

Description

go/parser: resolve identifiers properly Correctly distinguish between lhs and rhs identifiers and resolve/declare them accordingly. Collect field and method names in respective scopes (will be available after some minor AST API changes). Also collect imports since it's useful to have that list directly w/o having to re-traverse the AST (will also be available after some minor AST API changes). No external API changes in this CL.

Patch Set 1 #

Patch Set 2 : diff -r 31eae9ad9d23 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 31eae9ad9d23 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 31eae9ad9d23 https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r 31eae9ad9d23 https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 6 : diff -r 31d7feb9281b https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+213 lines, -101 lines) Patch
M src/pkg/go/parser/interface.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/go/parser/parser.go View 1 2 3 4 5 49 chunks +212 lines, -100 lines 0 comments Download

Messages

Total messages: 11
gri
Hello rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 11 months ago (2011-03-23 22:36:39 UTC) #1
rog
LGTM http://codereview.appspot.com/4271061/diff/9001/src/pkg/go/parser/interface.go File src/pkg/go/parser/interface.go (right): http://codereview.appspot.com/4271061/diff/9001/src/pkg/go/parser/interface.go#newcode72 src/pkg/go/parser/interface.go:72: x := p.parseRhs() it would be useful if ...
13 years, 11 months ago (2011-03-24 08:55:47 UTC) #2
rsc
> it would be useful if ParseExpr were to return the unresolved symbols in > ...
13 years, 11 months ago (2011-03-24 13:41:39 UTC) #3
rog
On 24 March 2011 13:41, Russ Cox <rsc@golang.org> wrote: >> it would be useful if ...
13 years, 11 months ago (2011-03-24 13:43:10 UTC) #4
rsc
LGTM It would be nice if a final pass rewrote the Obj pointers from unresolved ...
13 years, 11 months ago (2011-03-24 13:50:23 UTC) #5
rog
On 24 March 2011 13:50, <rsc@golang.org> wrote: > LGTM > > It would be nice ...
13 years, 11 months ago (2011-03-24 14:13:55 UTC) #6
rsc
LGTM Thanks Roger.
13 years, 11 months ago (2011-03-24 14:16:34 UTC) #7
gri
On Thu, Mar 24, 2011 at 6:50 AM, <rsc@golang.org> wrote: > LGTM Thanks for the ...
13 years, 11 months ago (2011-03-24 18:45:36 UTC) #8
gri
*** Submitted as http://code.google.com/p/go/source/detail?r=9c69f5573651 *** go/parser: resolve identifiers properly Correctly distinguish between lhs and rhs ...
13 years, 11 months ago (2011-03-24 18:46:00 UTC) #9
rsc
>> As is I believe client code must use Name == Name && Obj == ...
13 years, 11 months ago (2011-03-26 16:10:24 UTC) #10
gri
13 years, 11 months ago (2011-03-26 16:16:56 UTC) #11
On Sat, Mar 26, 2011 at 9:10 AM, Russ Cox <rsc@golang.org> wrote:
>>> As is I believe client code must use Name == Name && Obj == Obj in order
>>> to make sure an unresolved x is not treated the same as an unresolved y.
>>>  That would be cleaner as Obj != nil && Obj == Obj.
>>
>> I'm not sure I understand: As it is, if Obj != nil, two identifier
>> denote the same object if the Object ptrs are the same (at least
>> that's how it should be).
>
> I was missing the part in the code where it rewrites
> Obj == unresolved to Obj == nil.  Roger pointed it out
> for me.

yes, I saw that.
>
>> Two identifiers that are not resolved may or
>> may not denote the same object even if they have the same name.
>
> After resolving all the names that can be resolved within
> a single file, all that is left is unresolved references that
> will end up referring to an imported name or a top-level name
> declared in another file.  There can only be one of those
> in a valid package, so I believe it *is* true that two identifiers
> with Obj == nil and the same name do always refer to the
> same object.

good point. yes.
- robert

>
> Russ
>
Sign in to reply to this message.

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