go/types: CheckExpr doesn't return partial results #34248
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Darwin/amd64
What did you do?
I used
types.CheckExpr
to check the expression "foo{i}" in the package:What did you expect to see?
I expected to have some way to type check resiliently and get the type for my
*ast.CompositeLit
.See https://play.golang.org/p/dDqvcc-jSFM
What did you see instead?
The error for the un-type checkable "i" identifier is returned and no type checking is done. When using
*types.Checker
you can set the "Error" callback in the config so the type checker doesn't bail out, but CheckExpr doesn't set "Error" in the config.I was experimenting with
types.CheckExpr
in gopls to provide completions in the face of certain kinds of syntax errors, but its utility is limited because it isn't resilient to errors.The text was updated successfully, but these errors were encountered: