antlr4 icon indicating copy to clipboard operation
antlr4 copied to clipboard

Band-Aid "go vet" error with Go codegen template

Open SeanPMiller opened this issue 2 years ago • 8 comments

Resolves https://github.com/antlr/antlr4/issues/4439

This may not work forever. If it ever stops working, then we can switch to using a const variable, as that is how Rob Pike & Co. intend for debugging-logic to work. Refer to the following issue:

https://github.com/golang/go/issues/16370

SeanPMiller avatar Oct 17 '23 17:10 SeanPMiller

To any fellow travelers wondering how to get this (in lieu of this PR being merged), pipe your generated code through:

  tr '\n' '\f' | \
  sed 's|return localctx\f\tgoto errorExit // Trick to prevent compiler error if the label is not used|if false {\f          goto errorExit // Trick to prevent compiler error if the label is not used\f    }\f    return localctx|g' | \
  tr '\f' '\n'

simeonmiteff avatar Mar 25 '24 04:03 simeonmiteff

Given what a showstopper bug this is for Go developers, I'm surprised it has been languishing unmerged.

SeanPMiller avatar Apr 09 '24 19:04 SeanPMiller

Showstopper? Really? Why would you run go vet on generated code?

jimidle avatar Apr 09 '24 19:04 jimidle

Really. Have you tried to go vet a Go module that depends on another module generated by ANTLR?

SeanPMiller avatar Apr 09 '24 20:04 SeanPMiller

I'll excuse your obnoxious comment.

SeanPMiller avatar Apr 09 '24 20:04 SeanPMiller

Yeah. Sorry - I did not read this correctly. I will add it, but I am just overrun at the moment and have been for a whlie.

jimidle avatar Apr 09 '24 21:04 jimidle

Understood. I've been there. Are y'all short on volunteers?

SeanPMiller avatar Apr 09 '24 23:04 SeanPMiller