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

Compiler bug: using a static variable in a nested procedure #3380

Open
thetarnav opened this issue Apr 5, 2024 · 0 comments
Open

Compiler bug: using a static variable in a nested procedure #3380

thetarnav opened this issue Apr 5, 2024 · 0 comments
Labels

Comments

@thetarnav
Copy link
Contributor

If there is a @static struct variable declared in a procedure, and that variable is used with using inside a nested procedure, it results in an error.
I can't reproduce that error in any other way, so it seems like it was made exactly for that case?
But since assigning to state.foo works, I would expect that using should also work.

example

package bug

main :: proc() {
	@static state: struct {
		foo: int
	}

	nested :: proc() {
		state.foo = 1 // works
		
		using state
		foo = 2       // Error: Nested procedures do not capture its parent's variables: foo
	}
}

output

bug/bug.odin(12:3) Error: Nested procedures do not capture its parent's variables: foo
	foo = 2
	^~^

report

	Odin:    dev-2024-04:1422e5bc2
	OS:      Ubuntu 22.04.4 LTS, Linux 6.5.0-26-generic
	CPU:     Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
	RAM:     7631 MiB
	Backend: LLVM 17.0.6
@github-actions github-actions bot added the stale label Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant