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 functions in Haxe inherit this context from parent function #9

Open
alexeychikk opened this issue May 11, 2023 · 1 comment
Open
Labels
wontfix This will not be worked on

Comments

@alexeychikk
Copy link
Owner

alexeychikk commented May 11, 2023

class Foo {
  bar = 3;
}

export class Factory {
  static main() {
    Factory.createFoo(function () {
      console.log(this.bar); // in Haxe `this` causes compilation error, it's not accessible from static
    });
  }

  static createFoo(fn: (this: Foo) => Foo | void): Foo {
    const foo = new Foo();
    return fn.call(foo) ?? foo;
  }
}
@alexeychikk alexeychikk added the bug Something isn't working label May 11, 2023
@alexeychikk alexeychikk added wontfix This will not be worked on and removed bug Something isn't working labels May 19, 2023
@alexeychikk
Copy link
Owner Author

I don't see how this could be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant