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

ReferenceError / Instance prototype not found #11222

Open
dpomier opened this issue May 14, 2023 · 3 comments
Open

ReferenceError / Instance prototype not found #11222

dpomier opened this issue May 14, 2023 · 3 comments

Comments

@dpomier
Copy link
Contributor

dpomier commented May 14, 2023

The following sample yields on js and eval but not on hl or neko (Haxe 4.3.1 on https://try.haxe.org/#02bf26bF):

class Test {
	static var sub = new Sub();
	static function main() {}
}

@:keep class Sub extends Test {
	public function new() {}
}

JavaScript yields:

ReferenceError: can't access lexical declaration 'Test' before initialization

Eval yields:

[WARNING] Test.hx:1: lines 1-5

 1 | class Test {
 - |   [...]
 5 | }
   |
   | (WStaticInitOrder) Warning : maybe loop in static generation of Test

[ERROR] Test.hx:1: lines 1-5

 1 | class Test {
 - |   [...]
 5 | }
   |
   | [0] Instance prototype not found: Test
@Simn
Copy link
Member

Simn commented May 14, 2023

That code looks like you should get this warning on all targets... I wonder why only eval emits it.

Other than that I don't think there's anything to fix here.

@Aurel300
Copy link
Member

Why would this be a loop? I would accept that Sub needs to know the structure of Test to be able to extend it, but it does not need to know the static fields, because these are not inherited.

@Simn
Copy link
Member

Simn commented May 14, 2023

This depends on the generators, if all of them are fine with this then I agree we can make this work for JS and eval too. I would still like to know why that warning is target-dependent because the logic should be the same for all targets.

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