Skip to content

cmd/compile/internal/syntax: spurious 2nd syntax error in incorrect 'if' header #23406

@griesemer

Description

@griesemer

Parsing (go test -run Parse -src=x.go)

//+build ignore

package p

func bad() {
	if f()) {
		return
	}
}

results in:

parser_test.go:26: x.go:6:11: syntax error: unexpected ), expecting semicolon or newline
parser_test.go:26: x.go:6:11: syntax error: unexpected f, expecting { after if clause

The problem is due to an incorrectly set up variable when parsing statement headers.

The 2nd error is suppressed when using cmd/compile because it's on the same line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions