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

loop labels don't respect scope in switch statement #4366

Open
tadeohepperle opened this issue Oct 12, 2024 · 1 comment
Open

loop labels don't respect scope in switch statement #4366

tadeohepperle opened this issue Oct 12, 2024 · 1 comment

Comments

@tadeohepperle
Copy link
Contributor

Context

        Odin:    dev-2024-10:8006ba919
        OS:      Manjaro Linux, Linux 6.1.106-1-MANJARO
        CPU:     12th Gen Intel(R) Core(TM) i7-1260P
        RAM:     31806 MiB
        Backend: LLVM 14.0.6

Expected Behavior

This should work, since the outer labels are in different scopes:

ru := 'x'
	switch ru {
	case ' ', '\n':
		outer: for i in 0 ..= 10 {
			for j in 0 ..= 10 {
				if i == j {
					break outer
				}
			}
		}
	case:
		outer: for i in 0 ..= 10 {
			for j in 0 ..= 10 {
				if i == j {
					break outer
				}
			}
		}
	}

Similar to how this works, declaring an s variable in different scopes is fine:

main :: proc() {
	ru := 'x'
	switch ru {
	case ' ', '\n':
		s := "Hello"
	case:
		s := "Hello"
	}
}

Current Behavior

/home/tadeo/Desktop/test/o2/i.odin(24:3) Error: Duplicate label with the name 'outer' 
        outer: for i in 0 ..= 10 { 
        ^~~~^ 
@FourteenBrush
Copy link
Contributor

Labels are procedure bound, not scope bound

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