mirror of
https://github.com/golang/go
synced 2024-11-26 13:08:08 -07:00
[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>
This commit is contained in:
parent
edf80c4209
commit
dbce27d29c
@ -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
|
||||
}
|
||||
|
@ -2004,7 +2004,6 @@ var excluded = map[string]bool{
|
||||
"fixedbugs/issue22200.go": true, // types2 doesn't produce "stack frame too large" error
|
||||
"fixedbugs/issue22200b.go": true, // types2 doesn't produce "stack frame too large" error
|
||||
"fixedbugs/issue23732.go": true, // types2 reports different (but ok) line numbers
|
||||
"fixedbugs/issue24339.go": true, // types2 reports wrong line number
|
||||
"fixedbugs/issue25507.go": true, // types2 doesn't produce "stack frame too large" error
|
||||
"fixedbugs/issue25958.go": true, // types2 doesn't report a follow-on error (pref: types2)
|
||||
"fixedbugs/issue28079b.go": true, // types2 reports follow-on errors
|
||||
|
Loading…
Reference in New Issue
Block a user