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

cmd/compile: aliases should be used in error messages #40965

Closed
rsc opened this issue Aug 21, 2020 · 2 comments
Closed

cmd/compile: aliases should be used in error messages #40965

rsc opened this issue Aug 21, 2020 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Aug 21, 2020

Consider

package main

func main() {
	var (
		x rune
		y int
	)
	y = x
}

(https://play.golang.org/p/gA4OC1S_718).

The compiler error is:

./prog.go:8:4: cannot use x (type rune) as type int in assignment

Note the error (correctly) says rune, not int32. When we introduced rune and byte as aliases we were careful to preserve the right printing even though the two names were equivalent.

It appears the compiler does not extend the same courtesy to explicitly-defined aliases. If instead we use:

package main

func main() {
	var (
		x RUNE
		y int
	)
	y = x
}

type RUNE = int32

(https://play.golang.org/p/_7cffE6QOjo).

then the compiler error is:

./prog.go:8:4: cannot use x (type int32) as type int in assignment

It should say RUNE not int32.

@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 21, 2020
@rsc rsc added this to the Go1.16 milestone Aug 21, 2020
@cuonglm
Copy link
Member

cuonglm commented Aug 22, 2020

Duplicated with #21866

@ALTree
Copy link
Member

ALTree commented Aug 25, 2020

As it was pointed out, this is already tracked as #21866.

@ALTree ALTree closed this as completed Aug 25, 2020
@golang golang locked and limited conversation to collaborators Aug 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants