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

Reflect.callMethod doesn't work in Hashlink target #365

Closed
guifes opened this issue Apr 23, 2020 · 5 comments
Closed

Reflect.callMethod doesn't work in Hashlink target #365

guifes opened this issue Apr 23, 2020 · 5 comments

Comments

@guifes
Copy link

guifes commented Apr 23, 2020

var f = Reflect.field(Math, 'cos');
trace(Reflect.callMethod(Math, f, [1]));

This snippet crashes with the following error in runtime:

Uncaught exception: Invalid function null
Called from $Reflect.callMethod(/usr/local/lib/haxe/std/hl/_std/Reflect.hx:63)
Called from $Main.__constructor__(Main.hx:48)
Called from $DocumentClass.__constructor__(ApplicationMain.hx:267)

Works fine in cpp and html5 target though.

@kevinresol
Copy link

More importantly, this comes from the official example of hscript:
https://github.com/HaxeFoundation/hscript#example

@ncannasse
Copy link
Member

ncannasse commented Apr 23, 2020 via email

@guifes
Copy link
Author

guifes commented Apr 23, 2020

I'm compiling with whatever lime/openfl uses by default.

@ncannasse
Copy link
Member

You need to add -dce no or else the Math.cos function is optimized out.

@NotHyper-474
Copy link

Seems to be related to HaxeFoundation/hscript#96, even with -dce no Reflection on @:hlNative functions doesn't work in HashLink.

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