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

[php7] @:enum abstract properties #6175

Closed
benmerckx opened this Issue Apr 12, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@benmerckx
Contributor

benmerckx commented Apr 12, 2017

An enum abstract's properties are defined as const but the code will still try to set those same properties in __hx_init.

(The test method here has no other use than to force php to load Method_Impl_ because the property itself would get inlined.)

@:enum abstract Method(String) {
    var GET = 'GET';
    public static function test()
        return Method.GET;
}

class Main {
    static function main() {
        Method.test();
    }
}

Will result in:

final class Method_Impl_ {
	const GET = "GET";
	static public function test () {
		return "GET";
	}
	static public function __hx__init ()
	{
		// ....
		self::$GET = "GET"; // This should not be generated for const properties
	}
}

Which errors with:

Fatal error:  Uncaught Error: Access to undeclared static property: _Main\Method_Impl_::$GET
@RealyUniqueName

This comment has been minimized.

Show comment
Hide comment
@RealyUniqueName

RealyUniqueName Apr 12, 2017

Member

I cannot reproduce this issue with your example.
Which Haxe version do you use?

Member

RealyUniqueName commented Apr 12, 2017

I cannot reproduce this issue with your example.
Which Haxe version do you use?

@benmerckx

This comment has been minimized.

Show comment
Hide comment
@benmerckx

benmerckx Apr 12, 2017

Contributor

That's weird, just tested it on 3.4.0, 3.4.2 and ada466c and it's the same behaviour on all three.
By the way, it doesn't happen if -dce full is on (the const gets stripped).

Contributor

benmerckx commented Apr 12, 2017

That's weird, just tested it on 3.4.0, 3.4.2 and ada466c and it's the same behaviour on all three.
By the way, it doesn't happen if -dce full is on (the const gets stripped).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment