Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types: CheckExpr doesn't return partial results #34248

muirdm opened this issue Sep 11, 2019 · 1 comment

go/types: CheckExpr doesn't return partial results #34248

muirdm opened this issue Sep 11, 2019 · 1 comment


Copy link

@muirdm muirdm commented Sep 11, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13 darwin/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?


What did you do?

I used types.CheckExpr to check the expression "foo{i}" in the package:

package fake
type foo struct {}
var _  = foo{i}

What did you expect to see?

I expected to have some way to type check resiliently and get the type for my *ast.CompositeLit.


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.

@toothrot toothrot added the NeedsInvestigation label Sep 16, 2019
@toothrot toothrot added this to the Go1.14 milestone Sep 16, 2019
Copy link

@toothrot toothrot commented Sep 16, 2019

/cc @griesemer

@muirdm muirdm changed the title go/types: CheckExpr not resilient to errors go/types: CheckExpr doesn't return partial results Sep 19, 2019
@rsc rsc removed this from the Go1.14 milestone Oct 9, 2019
@rsc rsc added this to the Backlog milestone Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants