Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types, types2: error messages print untyped nil, compiler used to print just nil #48852

Closed
griesemer opened this issue Oct 7, 2021 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@griesemer
Copy link
Contributor

Maybe it's sufficient to just print nil where we print untyped nil in error messages. The untyped nil is printed to differenciate it from typed nil's, but now we print the type of typed nil's in parentheses.

Investigate.

Marked for 1.18 in case we consider it important for more concise error messages, but could easily be backlog.

cc: @findleyr

@griesemer griesemer added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 7, 2021
@griesemer griesemer added this to the Go1.18 milestone Oct 7, 2021
@griesemer griesemer self-assigned this Oct 7, 2021
@griesemer
Copy link
Contributor Author

Related: https://golang.org/cl/354631

@cuonglm
Copy link
Member

cuonglm commented Oct 8, 2021

To be clear, I think the compiler used to print just nil when constant involves, because technically, nil is not a constant. In other cases, the compiler does print untyped nil:

$ cat x.go
package p

var _ = copy(nil, []int{})
$ go tool compile -G=0 x.go
x.go:3:13: use of untyped nil

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/366276 mentions this issue: cmd/compile/internal/types2: print "nil" rather than "untyped nil"

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/366277 mentions this issue: go/types: print "nil" rather than "untyped nil"

gopherbot pushed a commit that referenced this issue Nov 24, 2021
This is a port of CL 366276 from types2 to go/types
with minor adjustments due to the slightly different
handling of nil in go/types.

It uses some more detailed error strings in stmt0.src;
the same changes are made to the corresponding types2
file.

For #48852.

Change-Id: I2cdf258799bcbe2d12bbadaf67b8b4504b356bd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/366277
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants