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

variable re-definition error on if scope #29

Open
Delta456 opened this issue Mar 17, 2025 · 1 comment
Open

variable re-definition error on if scope #29

Delta456 opened this issue Mar 17, 2025 · 1 comment

Comments

@Delta456
Copy link
Member

Describe the bug

I get an error for the method redefinition but it shouldn't error because it is in the if scope which is different for each if scope

Image

Expected Behavior

There should be no error in this

Current Behavior

There is an error

Reproduction Steps

Given already. This can be seen in vlang/v#23967 for a clear idea

Possible Solution

No response

Additional Information/Context

No response

Environment details (v doctor output)

Not Required for this

IDE Type (IDEA Community/Ultimate, GoLand, CLion, etc.)

IDEA Ultimate

Plugin Version

Latest

@Krotki
Copy link
Contributor

Krotki commented Mar 17, 2025

It only happens on else branch of IfGruard expression, where a given var is none. Original a seem to be still in scope.

fn main() {
	aaa := ?int(none)
	bbb := ?int(1)

	if a := aaa {
		println("aaa: $a")
	} else {
		if a := bbb {
			println("bbb: $a")
		}
	}
	if a := bbb {
		println("bbb: $a")
	}
}

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

No branches or pull requests

2 participants