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: more robust error handling #11377
I'm going to try to start filing bugs against go/parser when I notice things that trigger less than ideal error messages in the course of ordinary usage (via goimports, go test, and so on), because I think there are some simple cases that can be improved. I expect most of the initial ones will be about getting too many errors. Here's the first one.
This is a reduced version of a real case I had, where an extra paren in a function near the top of a long source file triggered many many messages. In this program, the braces are still balanced, so there should be a good signal for the parser to recover by the end of the function (and ideally the end of the enclosing block, although here they are the same).
This is a case where the yacc grammar's error recovery is actually doing better:
Also the IDENT in the go/parser error is probably not helpful to the user. It's an internal detail.
R=go1.11 This is a follow up for #11377 which reported that an error like /tmp/xx.go:9:6: expected '(', found 'IDENT' F1 shouldn't print 'IDENT', as it's just an internal detail. The relevant change wasn't made in the original fix, so here it is. For #11377. Change-Id: Ib76957d86b88e3e63646fbe4abf03a3b9d045139 Reviewed-on: https://go-review.googlesource.com/87900 Reviewed-by: Matthew Dempsky <email@example.com>