Skip to content

local static doesn't like local functions #11919

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

Closed
Antriel opened this issue Jan 16, 2025 · 2 comments · Fixed by #11999
Closed

local static doesn't like local functions #11919

Antriel opened this issue Jan 16, 2025 · 2 comments · Fixed by #11999
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

Simn added a commit that referenced this issue Feb 11, 2025
Simn added a commit that referenced this issue Feb 11, 2025
* start dealing with static inits properly

see #11919

* maybe PHP needs this too

* and Flash as well

* fix
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

Successfully merging a pull request may close this issue.

3 participants