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

Incorrect Variable Assignment #2637

Closed
omarsy opened this issue Jul 27, 2024 · 0 comments · Fixed by #2206
Closed

Incorrect Variable Assignment #2637

omarsy opened this issue Jul 27, 2024 · 0 comments · Fixed by #2206

Comments

@omarsy
Copy link
Member

omarsy commented Jul 27, 2024

Description:

Issue Summary:

An incorrect number of values can be assigned to a set of variables without triggering an error. The following code, which should produce a compilation error, works in Gnolang and returns incorrect output:

package main

import "fmt"

func main() {
	a, c := 1, 2, 3
	fmt.Println(a, c)
}

Expected Behavior:

The code should result in an error stating:

assignment mismatch: 2 variables but 3 values

Actual Behavior:

the code compiles and runs, producing the output:

2 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

1 participant