]> Cypherpunks.ru repositories - gostls13.git/commit
go/types: correct error position for inherited const init expressions
authorRob Findley <rfindley@google.com>
Tue, 8 Dec 2020 14:44:48 +0000 (09:44 -0500)
committerRobert Findley <rfindley@google.com>
Tue, 8 Dec 2020 19:45:23 +0000 (19:45 +0000)
commit01b76d5fbc4d4acdd28b08a061b072b73b22f44e
tree01c49c26cbd469a94049eb33818914593b100a04
parent48d6275952184f1e858c2796d36c6b205d5d7e83
go/types: correct error position for inherited const init expressions

This is a port of CL 275517 from the dev.typeparams branch, to fix the
positioning of error messages for invalid const init expressions that
are inherited.

Differences from CL 275517:
 + The inherited flag is added to the constDecl intermediate
   representation.
 + The errpos override is made a positioner, the internal interface
   used by go/types to capture error position and span. For const decls
   errpos is just set to a singular point, but using positioner is
   correct and causes span start and end positions to also be
   overridden.
 + Test cases are updated to assert on just 'overflows', as the go/types
   error message is, for example, "cannot use 255 + iota (untyped int
   constant 256) as byte value in constant declaration (overflows)".
   This is more verbose than the compiler's "constant 256 overflows
   byte", but changing that is out of scope.

Fixes #42991

Change-Id: I0a71d2290f7fff5513f2a6e49b83e6f0f4da30e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/276172
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/check.go
src/go/types/decl.go
src/go/types/errors.go
src/go/types/resolver.go
src/go/types/testdata/constdecl.src