You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
go/parser: bad error recovery for simple program with missing function name #63834
package p
func (xstring) []byte {
return []byte(x)
}
produces (when run as test under go/types):
check_test.go:168: testdata/manual.go:10:17: expected 'IDENT', found '['
check_test.go:168: testdata/manual.go:10:18: expected '(', found ']'
check_test.go:168: testdata/manual.go:10:24: missing ',' in parameter list
check_test.go:168: testdata/manual.go:11:9: expected ')', found 'return'
check_test.go:168: testdata/manual.go:11:17: missing ',' in parameter list
check_test.go:168: testdata/manual.go:11:25: missing ',' before newline in parameter list
check_test.go:168: testdata/manual.go:12:1: expected ')', found '}'
check_test.go:168: testdata/manual.go:12:1: missing ',' in parameter list
check_test.go:168: testdata/manual.go:12:2: expected ')', found 'EOF'
check_test.go:168: testdata/manual.go:12:2: expected ')', found newline
check_test.go:168: testdata/manual.go:12:2: expected ';', found 'EOF'
check_test.go:168: testdata/manual.go:12:2: missing ',' before newline in parameter list
Hi, first time contributor here
Is there someone working on this issue? It seems that the parseFuncDecl function in the go/parser package does not check syntax errors during function declaration if it does not conform to the usual two forms (methods and usual functions), and that is causing the cascade of errors seen.
Me and some colleagues would be interested in solving this
@lucasgpulcinelli Nobody is working on this at the moment. Feel free to give it a shot. One word of caution, if I may: whatever your potential fix, please don't simply look for the particular pattern causing the problem here - it's an easy pitfall. As an aside, you might also want to look at cmd/compile/internal/syntax/parser.go which has better error recovery. Thanks.
Activity
griesemer commentedon Oct 30, 2023
For the reference, the syntax parser produces just one error (also run under types2 test harness):
(but then types2 crashes).
lucasgpulcinelli commentedon Nov 16, 2023
Hi, first time contributor here
Is there someone working on this issue? It seems that the parseFuncDecl function in the go/parser package does not check syntax errors during function declaration if it does not conform to the usual two forms (methods and usual functions), and that is causing the cascade of errors seen.
Me and some colleagues would be interested in solving this
griesemer commentedon Nov 16, 2023
@lucasgpulcinelli Nobody is working on this at the moment. Feel free to give it a shot. One word of caution, if I may: whatever your potential fix, please don't simply look for the particular pattern causing the problem here - it's an easy pitfall. As an aside, you might also want to look at cmd/compile/internal/syntax/parser.go which has better error recovery. Thanks.
gopherbot commentedon Nov 27, 2023
Change https://go.dev/cl/545075 mentions this issue:
go/parser: improve error detection while parsing functions