diff options
author | Robert Griesemer <gri@golang.org> | 2020-12-09 15:49:04 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2020-12-10 00:09:51 +0000 |
commit | dbce27d29c8479d969aad5be4658fde32ff3f1e4 (patch) | |
tree | 56b8d23f4e6b1c74ba4ca3e39316fbc1dd8907e8 /src/cmd/compile/internal/types2/expr.go | |
parent | edf80c4209a03bc656edfa5222b8fbd7fd072401 (diff) | |
download | go-dbce27d29c8479d969aad5be4658fde32ff3f1e4.tar.gz go-dbce27d29c8479d969aad5be4658fde32ff3f1e4.zip |
[dev.typeparams] cmd/compile/internal/types2: report correct line number for missing key
Use the Key position of a syntax.KeyValueExpr (not the position of the
":") when reporting an error for a missing key.
(In go/types, the KeyValueExpr position is the start of the expression
not the ":", so there this works as expected.)
Change-Id: I74147d245927847274cf4e53b4f03dbb5110c324
Reviewed-on: https://go-review.googlesource.com/c/go/+/276813
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/expr.go')
-rw-r--r-- | src/cmd/compile/internal/types2/expr.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 2fabd9694e..252d4814cc 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -1277,9 +1277,9 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin i := fieldIndex(utyp.fields, check.pkg, key.Value) if i < 0 { if check.conf.CompilerErrorMessages { - check.errorf(kv, "unknown field '%s' in struct literal of type %s", key.Value, base) + check.errorf(kv.Key, "unknown field '%s' in struct literal of type %s", key.Value, base) } else { - check.errorf(kv, "unknown field %s in struct literal", key.Value) + check.errorf(kv.Key, "unknown field %s in struct literal", key.Value) } continue } |