Skip to content

go/parser accepts illegal expressions #2155

@griesemer

Description

@griesemer
The go/parser accepts type literals instead if proper (value) expressions in several
cases; e.g.:

package p

func _() {
    _ = []int{[]int}
    _ = ([]int)
    _ = a[[]int : []int]
    _ = f([]int, []int)
    _ <- []int
    _ = []int(0)
    select {
    case _ <- []int:
    }
}

is parsed w/o syntax errors.

There is a respective TODO in go/parser:1365 (parseExpr(lhs bool) ast.Expr method).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions