-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/types, types2: report type name in comp. literal error, if possible
When reporting an error for the element type of a struct literal, use the element type's type name rather than it's underlying/core type. Also, combine error reporting for invalid composite literal types in one place, at the end. Fixes golang#68184. Change-Id: I1f407d5403777948da9a0eca95aacc1389f4bd44 Reviewed-on: https://go-review.googlesource.com/c/go/+/595075 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Robert Griesemer <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Tim King <[email protected]>
- Loading branch information
Showing
3 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package p | ||
|
||
type VeryLongStruct struct { | ||
A1 int | ||
A2 int | ||
A3 int | ||
A4 int | ||
A5 int | ||
A6 int | ||
A7 int | ||
A8 int | ||
A9 int | ||
A10 int | ||
A11 int | ||
A12 int | ||
A13 int | ||
A14 int | ||
A15 int | ||
A16 int | ||
A17 int | ||
A18 int | ||
A19 int | ||
A20 int | ||
} | ||
|
||
func _() { | ||
// The error messages in both these cases should print the | ||
// struct name rather than the struct's underlying type. | ||
|
||
var x VeryLongStruct | ||
x.B2 /* ERROR "x.B2 undefined (type VeryLongStruct has no field or method B2)" */ = false | ||
|
||
_ = []VeryLongStruct{{B2 /* ERROR "unknown field B2 in struct literal of type VeryLongStruct" */ : false}} | ||
} |