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: inconsistent error message for assignment mismatch #30085

Closed
smasher164 opened this issue Feb 5, 2019 · 4 comments
Closed

cmd/compile: inconsistent error message for assignment mismatch #30085

smasher164 opened this issue Feb 5, 2019 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@smasher164
Copy link
Member

Example runs on playground with go1.11.1.
https://play.golang.org/p/UoxPKcFBMCG

package main

func main() {
	var a, b = 1 // prog.go:4:6: assignment mismatch: 2 variables but 1 values
	var c, d = 1, 2, 3 // prog.go:5:6: extra expression in var declaration
	var e, f, g = 1, 2 // prog.go:6:6: missing expression in var declaration
	h, i, j := 1, 2 // prog.go:7:10: assignment mismatch: 3 variables but 2 values
}

The two messages in the middle for “extra” and “missing” expressions don’t actually point to the offending expression that unbalances the assignment, making the message less useful. Moreover, a slight modification to the Lhs and Rhs results in the much more clear, “assignment mismatch” message. In my opinion, all of these declarations should result in the assignment mismatch error.

@agnivade
Copy link
Contributor

agnivade commented Feb 5, 2019

While triaging this, I found a bigger problem which is a regression introduced in the 1.12 cycle. Filed #30087

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 5, 2019
@andybons andybons added this to the Unplanned milestone Feb 5, 2019
@andybons
Copy link
Member

andybons commented Feb 5, 2019

@dddent

@gopherbot
Copy link

Change https://golang.org/cl/161558 mentions this issue: cmd/compile: return assignment mismatch error in var declarations

@smasher164
Copy link
Member Author

Sent in a follow-up CL, but there's obviously no rush for 1.12.

@andybons andybons added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 7, 2019
@golang golang locked and limited conversation to collaborators Apr 2, 2020
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