Navigation Menu

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
muirdm opened this issue Sep 11, 2019 · 1 comment
Open

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

muirdm opened this issue Sep 11, 2019 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@muirdm
Copy link

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?

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 the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 16, 2019
@toothrot toothrot added this to the Go1.14 milestone Sep 16, 2019
@toothrot
Copy link
Contributor

/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 modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants