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

[HashLink] Uncaught exception: Can"t cast dynobj to #Foo #6206

Open
SlavaRa opened this issue Apr 26, 2017 · 8 comments
Open

[HashLink] Uncaught exception: Can"t cast dynobj to #Foo #6206

SlavaRa opened this issue Apr 26, 2017 · 8 comments
Milestone

Comments

@SlavaRa
Copy link
Member

SlavaRa commented Apr 26, 2017

code for example:

package;

class Main {
	
	static function main() {
		Reflect.callMethod({}, new Foo().test, []);
	}
}

class Foo {
	public function new() {}
	
	public function test() {
		trace("test");
	}
}

Flash - ok
JS - ok
CPP - ok
CS - ok
Java - ok
Neko - ok

HashLink result:

Uncaught exception: Can"t cast dynobj to #Foo
Called from $Reflect.callMethod(C:\HaxeToolkit\haxe\std/hl/_std/Reflect.hx:85)
Called from $Main.main(Main.hx:6)
Called from fun$337(?:1)
@ncannasse
Copy link
Member

You need to use "null" for Reflect.callMethod object, in case of a closure it seems the obj is ignored in other targets, we might want to fix that. Using null should work everywhere.

@Simn
Copy link
Member

Simn commented Apr 26, 2017

Ignoring it seems fine to me, especially if that what all targets do already.

@RealyUniqueName
Copy link
Member

PHP generators don"t ignore obj

@ncannasse
Copy link
Member

That requires some additional unit test

@Simn
Copy link
Member

Simn commented Apr 26, 2017

But what is the expected behavior?

@Simn Simn added the platform-hl Everything related to HashLink label May 29, 2017
@ncannasse
Copy link
Member

This is not HL specific, we need to specify and unit test what Reflect.callMethod(obj,fun,args) does when obj != null and fun is a closure on another object. I think this should be an error, unless obj == closure object, if this can be checked easily on all platforms.

@ncannasse ncannasse removed the platform-hl Everything related to HashLink label Feb 25, 2018
@RealyUniqueName
Copy link
Member

RealyUniqueName commented Feb 25, 2018 via email

@ncannasse
Copy link
Member

@RealyUniqueName that"s a bit tricky, but we would have to ensure that both objects are of the same type

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

4 participants