-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types: wrong line numbers in errors for constant overflows involving iota #42991
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
Comments
One possibility might be to remember a line correction delta when we evaluate an expression containing an iota. The line correction delta is the iota value. Follow-up: @findleyr I think I've got a fairly simple fix for this. Need to rethink/test/clean up etc. but hopefully should be ready sometime tomorrow or over the weekend. |
Thanks for investigating this @griesemer. I'm not sure I understand your point about using the iota value to compute correction delta, since there need not be any correlation between iota value and line number, for example https://play.golang.org/p/FQfRsDMMv8v. |
@findleyr Yes, you're correct - I've realized that last night as well. Turns out we just need to remember the position of the actual constant being initialized; in fact we need that position anyway to be able to position the error correctly. In short: Whenever we evaluate a constant initialization expression that is "inherited" from (shared with) other constants, we remember the position of the constant identifier. If there's an error in the initialization expression, we use the position of the constant identifier (this is stored in the current Checker context) for the error location (and we can still point to the original expression as well). |
Change https://golang.org/cl/275517 mentions this issue: |
…for inherited const init expression Enabled fixedbugs/issue8183.go for run.go with new typechecker now that issue is fixed. Fixes #42992. Updates #42991. Change-Id: I23451999983b740d5f37ce3fa75ee756daf1a44f Reviewed-on: https://go-review.googlesource.com/c/go/+/275517 Trust: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]>
Change https://golang.org/cl/276172 mentions this issue: |
produces
yet the correct line numbers are 15, 21, and 22.
The text was updated successfully, but these errors were encountered: