Skip to content

cmd/compile: check that all n.Val() uses checked for a nil n.Type #22001

@mvdan

Description

@mvdan

If there was an error in a program related to n, such as the use of an undefined name to declare it, the node may be incomplete. In particular, using n.Val() can cause panics, as is the case of n.Val().Interface().

A recent example: #21988

We should check the compiler to see if there are other instances of n.Val() use without us checking for n.Type == nil (or n.Type != nil). Ideally in an automated manner, as there are more than a hundred .Val() method calls in the gc package.

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