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
Milestone

Comments

@rsc
Copy link
Contributor

@rsc 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 label Aug 21, 2020
@rsc rsc added this to the Go1.16 milestone Aug 21, 2020
@cuonglm
Copy link
Contributor

@cuonglm cuonglm commented Aug 22, 2020

Duplicated with #21866

@ALTree
Copy link
Member

@ALTree ALTree commented Aug 25, 2020

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

@ALTree ALTree closed this Aug 25, 2020
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
3 participants
You can’t perform that action at this time.