-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/gopls: panic in analyzer due to type checker errors #32413
Comments
I've found the panics are not directly related to build tags. They happen when you have type checker error like having two functions of the same name. The crash is reproducible by defining the function "Foo" twice in one package, then opening another package that imports the first package. In particular, one of the "Foo" methods has no type information since it is not valid, and some of the analyzers assume that *ast.FuncDecl nodes have type information. The panic seems to have started after this change golang/tools@08bd53a. @stamblerre do you think this is a gopls bug and it shouldn't be invoking the analyzers, or should the analyzers not crash in this case? |
No analyzer that sets RunDespiteErrors should crash on things that did not type check, so I would say this is a problem with the analyzer. |
The two analyzers in question don't set RunDespiteErrors. gopls used to define "errors" as |
Ah, I think my reasoning here was to sort of hide the problems caused by build tags, but of course it always comes back to build tags. Basically, you get false errors from packages with build tags, and then any package that imports those can't run analyzers because there are no results from the dependency packages. I guess the real solution here is to figure out how to handle build tags... |
Duplicate of #33689 |
Edit: I've narrowed the issue down further, see follow up comment below.
I'm seeing these two separate crashes on master (08e0b30).
I've narrowed it down to this repro involving build tags:
To reproduce:
p1.go
(I'm using go1.12, so this file doesn't apply to my build)p2.go
, witness panicI tried in VSCode and it didn't seem to reproduce as easily, so here is me Emacs lsp debug log:
The text was updated successfully, but these errors were encountered: