]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/types2: report correct line number for missing key
authorRobert Griesemer <gri@golang.org>
Wed, 9 Dec 2020 23:49:04 +0000 (15:49 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 10 Dec 2020 00:09:51 +0000 (00:09 +0000)
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>
src/cmd/compile/internal/types2/expr.go
test/run.go

index 2fabd9694e467761385d1795024e694dbff6a4c3..252d4814cc3ad153141d53eab5ff80e1dcde898b 100644 (file)
@@ -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
                                        }
index 1932c9e6102a1cd070c8479c5feddda17a914150..db8bffc81fe490953c5facab7e832c4beab9d075 100644 (file)
@@ -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