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

Open
muirrn opened this issue Sep 11, 2019 · 1 comment

Comments

@muirrn
Copy link

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?

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:

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.

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.

@toothrot toothrot added this to the Go1.14 milestone Sep 16, 2019

@toothrot

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2019

@muirrn muirrn changed the title go/types: CheckExpr not resilient to errors go/types: CheckExpr doesn't return partial results Sep 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.