Math.cos example fails when targeting HashLink
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- compilers
Research direction
Reproduce the issue using the Haxe example with HashLink, then compare the hscript interpreter behavior with the working JS and interp targets. Inspect the Math lookup exposed through interp.variables and the failing Reflect.getProperty(Math, "cos") call; done means Math.cos resolves and the example produces the expected result on HashLink.
Written by the indexing model from the issue text.
Description
While trying to follow the example code
var script = "
var sum = 0;
for( a in angles )
sum += Math.cos(a);
sum;
";
var parser = new hscript.Parser();
var program = parser.parseString(script);
var interp = new hscript.Interp();
interp.variables.set("Math",Math); // share the Math class
interp.variables.set("angles",[0,1,2,3]); // set the angles list
trace( interp.execute(program) );
with latest haxe 4.1.2 and hashlink 1.11.0, I get the error "Invalid function null" when it tries to find the cos function in Math. This -appears- to be a hashlink bug? But I'm not entirely sure if maybe there's a way around it that should be done in hscript instead.
The code executes as expected with both js and interp.
Reflect.getProperty(Math, "cos"); //null for HashLink target
- Dominant language
- Haxe
- Stars
- 309
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from HaxeFoundation/hscript
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
HaxeFoundation/hscript#166 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
HaxeFoundation/hscript#161 · 1 comment ·
-
Haxe4 try-catchOpen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
HaxeFoundation/hscript#144 · 3 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
HaxeFoundation/hscript#109 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
HaxeFoundation/hscript#98 · 1 reaction ·
All issues in HaxeFoundation/hscript
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
I-prioritize needs-triage regression-from-stable-to-beta T-lang
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/rust#163830 · 1 comment ·
Maintainers usually reply within 1 day
-
Swift route tables omit digit constraints from generated main and testsPossibly taken @dchuk claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rubys/roundhouse#444 ·
Maintainers usually reply within 1 day
-
IntrinsicLowering::LowerCTPOP runs into assertion with LLVM 23Possibly taken A pull request linked to this issue is open or already merged. Opencrash llvm:codegen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
llvm/llvm-project#229064 ·
Maintainers usually reply within 1 day
-
area:lowering kind:bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day