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

Open
griesemer opened this issue Oct 7, 2021 · 2 comments
Assignees
Milestone

Comments

@griesemer
Copy link
Contributor

@griesemer griesemer commented Oct 7, 2021

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 this to the Go1.18 milestone Oct 7, 2021
@griesemer griesemer self-assigned this Oct 7, 2021
@griesemer
Copy link
Contributor Author

@griesemer griesemer commented Oct 7, 2021

@cuonglm
Copy link
Member

@cuonglm 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants