fatih / errwrap

Go tool to wrap and fix errors with the new %w verb directive
https://arslan.io
Other
371 stars 16 forks source link

Don't clobber the AST when generating suggested fixes #15

Closed reillywatson closed 2 years ago

reillywatson commented 2 years ago

analysis/unitchecker calls multiple analyzers in parallel, using the same AST. This creates a race where clobbering the AST might result in unexpected behaviour from other linters. In particular, linters that use the buildssa analyzer can panic with an error about a non-constant BasicLit, because it builds up a set of constants and then expects that set to be the same later in its analysis process.

Instead make a new CallExpr, and use that for the rewriting step.

fatih commented 2 years ago

Thanks for the fix @reillywatson