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/cppia] lazily-initialized (get, null) property #6281

Closed
Gama11 opened this Issue May 14, 2017 · 3 comments

Comments

Projects
None yet
5 participants
@Gama11
Member

Gama11 commented May 14, 2017

The following fails on PHP7:

class Main {
	public static var syntaxes(get, null):String;

	static function get_syntaxes():String {
		if (syntaxes == null)
			syntaxes = "foo";
		return syntaxes;
	}

	public static function main() {
		trace(syntaxes);
	}
}
PHP Fatal error:  Uncaught Error: Access to undeclared static property: Main::$syntaxes in php/lib/Main.php:19
Stack trace:
#0 php/lib/Main.php(33): Main::get_syntaxes()
#1 php/index.php(13): Main::main()
#2 {main}
  thrown in php/lib/Main.php on line 19

Isolated from the markdown lib. Haxe version: acc026c

@szczepanpp

This comment has been minimized.

Show comment
Hide comment
@szczepanpp

szczepanpp May 14, 2017

I wonder if it's a bug or not. I'm simply adding @:isVar on the property and always assumed it's a target specific behaviour (e.g. it can work on JS without annotation because in JS you can use variables not declared explicitly).

Now, looking at Haxe documentation (https://haxe.org/manual/class-field-property-rules.html), it states that a property with the read-access or write-access identifier being default or null is considered physical, which in turn prevents Haxe compiler only from throwing a compilation error. Documentation doesn't say how the field is defined in terms of using annotation or just working on a specific (dynamic) target.

szczepanpp commented May 14, 2017

I wonder if it's a bug or not. I'm simply adding @:isVar on the property and always assumed it's a target specific behaviour (e.g. it can work on JS without annotation because in JS you can use variables not declared explicitly).

Now, looking at Haxe documentation (https://haxe.org/manual/class-field-property-rules.html), it states that a property with the read-access or write-access identifier being default or null is considered physical, which in turn prevents Haxe compiler only from throwing a compilation error. Documentation doesn't say how the field is defined in terms of using annotation or just working on a specific (dynamic) target.

@Gama11

This comment has been minimized.

Show comment
Hide comment
@Gama11

Gama11 May 14, 2017

Member

This works on C++, C#, Java, Neko, HL, JS, Flash, Lua, Python and the old PHP target. I'd say it's a bug. ;)

Member

Gama11 commented May 14, 2017

This works on C++, C#, Java, Neko, HL, JS, Flash, Lua, Python and the old PHP target. I'd say it's a bug. ;)

@Gama11

This comment has been minimized.

Show comment
Hide comment
@Gama11

Gama11 May 15, 2017

Member

Looks like this may need to be reopened, cppia is failing on the unit test:

Issue6281.hx:11: foo should be 0
Test.hx:221: DONE [6890 tests]
Test.hx:222: SUCCESS: false
Command exited with 1 in 0s: /home/travis/build/HaxeFoundation/haxe/tests/unit/bin/cppia/Host-debug [bin/unit.cppia]
test cpp failed

@hughsando

Member

Gama11 commented May 15, 2017

Looks like this may need to be reopened, cppia is failing on the unit test:

Issue6281.hx:11: foo should be 0
Test.hx:221: DONE [6890 tests]
Test.hx:222: SUCCESS: false
Command exited with 1 in 0s: /home/travis/build/HaxeFoundation/haxe/tests/unit/bin/cppia/Host-debug [bin/unit.cppia]
test cpp failed

@hughsando

@Gama11 Gama11 changed the title from [php7] lazily-initialized (get, null) property to [php7/cppia] lazily-initialized (get, null) property May 15, 2017

@Simn Simn reopened this May 15, 2017

@Simn Simn assigned hughsando and unassigned RealyUniqueName May 15, 2017

Simn added a commit that referenced this issue May 16, 2017

Gama11 added a commit to Gama11/haxe that referenced this issue May 23, 2017

Simn added a commit that referenced this issue May 23, 2017

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