Skip to content

Cannot use fields of anonymous field in struct literal #164

Closed
@gopherbot

Description

@gopherbot

by kirklin.mcdonald:

The following code gives the following error:

$ cat test.go
package test

type A struct {
    X int;
}

type B struct {
    A;
    Y int;
}

var b = B{X: 20, Y: 12}
$ 6g -o test.6 test.go
test.go:12: b.X undefined (type B has no field X)

Given that X is a valid field of B, I would expect this to be a valid 
struct literal.

Additional information:
$ echo $GOARCH $GOOS
amd64 linux
$ hg log -l1
changeset:   4037:cd0140653802

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions