Open
Description
ParseExprFrom
is documented as such:
Lines 193 to 198 in c8fb6ae
From the docs it is clear that, if reading the source succeeds, then the returned Expr shoudn't be nil, but it is not actually true (in case of a bailout, also see #70725).
Reproducer:
func TestEarlyBailout2(t *testing.T) {
const src = `func() {
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
func () { var a }
}()
`
fset := token.NewFileSet()
expr, err := ParseExprFrom(fset, "test.go", src, SkipObjectResolution|ParseComments)
t.Log(expr, err) // <nil> test.go:2:19: expected type, found '}' (and 10 more errors)
}
Same with ParseExpr
:
Lines 243 to 248 in c8fb6ae
Per docs it should not return a nil ast.Expr
.