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

local static doesn't like local functions #11919

Open
Antriel opened this issue Jan 16, 2025 · 2 comments
Open

local static doesn't like local functions #11919

Antriel opened this issue Jan 16, 2025 · 2 comments
Assignees

Comments

@Antriel
Copy link
Contributor

Antriel commented Jan 16, 2025

function main() {
	var ok = new Func(a -> a);
	static var err = new Func(a -> a);
//                                ^^^^^^
// Accessing local variables in static initialization is not allowed
}

class Func {
  public function new(f:Int->Int) {}
}
@Simn Simn self-assigned this Jan 17, 2025
@Simn
Copy link
Member

Simn commented Jan 17, 2025

That should apply to all expressions that introduce local variables. We'll have to track which variables are defined in our initialization expression.

@kLabz
Copy link
Contributor

kLabz commented Jan 22, 2025

I guess that is another instance of this issue?

 ERROR  src/XmlDisplayTestCase.hx:16: characters 35-66

 16 |   static var args = ['--display', haxe.Json.stringify(methodArgs)];
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | Accessing local variables in static initialization is not allowed

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

3 participants