Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #294
NB: This patch should fix the bug in #294, but there is still room for greater discussion around how we access fields from other nodes. We can discuss here before merging, or merge and add an issue for refactoring the way that this works when we have a clear way forward.
The specific behavior we will now observe for exported field names is:
Names from anonymous structs are exported. For example we may
access
b.Foo
directly when given a b of type B as show below:Named fields supercede fields exported by embdded structs. For
example, calling
b.Bar
in the example below would returnb.bar
nota.b.bar
Fields in an anonymous struct MAY be accessed by their type name.
In the example above we may call
b.a.bar
which would give usa.bar
. Likewise it is valid, but unnecessary, to reference Foo bycalling
b.a.foo
.Overlapping fields are not exported, but do not result in an error.
In the example below, an error would be generated only when attempting
to access
a.foo
, however we may accessa.bar
they will not be exported directly, they may however be accessed using
their field type name as shown in (3). In the example below
a.b.foo
and
a.c.foo
are valid, buta.foo
is not.