intellij-v icon indicating copy to clipboard operation
intellij-v copied to clipboard

variable re-definition error on if scope

Open Delta456 opened this issue 9 months ago • 1 comments

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 https://github.com/vlang/v/pull/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

Delta456 avatar Mar 17 '25 19:03 Delta456

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")
	}
}

Krotki avatar Mar 17 '25 21:03 Krotki