Skip to content

go/types, types2: be consistent about how to check for invalid operands internally (code audit) #76110

@griesemer

Description

@griesemer

The type checker uses the invalid operand mode to indicate an invalid operand. It does not in general assume that the operand's type is invalid in that case.

Should audit the code to make sure we don't use an operand's type if the operand is invalid. Alternatively, perhaps we should use accessors such as operand.isValid and operand.setInvalid. Writing !x.isValid() is shorter than x.mode == invalid and x.setInvalid() is slightly shorter than x.mode = invalid and it could also set the type to Typ[Invalid].

There may be other alternatives that are cheap in the non-error case.

Metadata

Metadata

Labels

ImplementationIssues describing a semantics-preserving change to the Go implementation.

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions