Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
go/parser: emits invalid ast for Decl with missing type. #9639
The following code
However, go/parser parses it without returning an error. Code: http://play.golang.org/p/F2J2uFWvDu.
I expected to receive a syntax error like "unexpected semicolon or newline". Instead, no error and an ast containing a Decl with Type nil is emited.
Go version in playground at time of report: go1.3.2
The go/parser deliberately accepts a larger language than what the spec permits, for more lenient parsing which permits better error messages later. If you run through go/types, you will get the error:
$ gotype z.go
Perhaps in this case the parser could be tightened a bit.
It's trivial to add a verification pass if this is required. This is issue is not urgent.