Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Math.cos example fails when targeting HashLink

Open
#96 3 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HaxeFoundation/hscript

All issues in HaxeFoundation/hscript

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.