Haxe compiler outputs garbage randomly (about every second run)

Hello,

just wondering if anyone has seen something similar.

I’m running a pretty standard haxe-to-js pipeline.

At some point, my project broke (grew too big?) and now - on about every second run - the build fails due to the generated JS code containing garbage output (see below).

The error in the web browser console reads:

MyApplication.js:1223 Uncaught SyntaxError: Unexpected template string
(index):39 Uncaught ReferenceError: lime is not defined
    at (index):39:3
(anonymous) @ (index):39

Here is my project.xml:

<?xml version="1.0" encoding="utf-8"?>
<project>
	<meta title="Graphica" package="com.example.Graphica" version="1.0.0" company="My Company"/>
	<app main="Main"/>
	
	<window allow-high-dpi="true"/>
	<window fps="60"/>
	<window fps="0" if="html5"/>
	
	<source path="src"/>
	
	<haxelib name="openfl"/>
	<haxelib name="actuate"/>
	<haxelib name="feathersui"/>
	<haxelib name="thenshim"/>
	<haxedef name="HXCPP_ARCH=arm64" />

	<icon path="assets/icons/icon.svg"/>
</project>

Here is the spuriously inserted code that causes problems in MyApplication.js:

openfl_Vector.ofArray_Int = function(array) {
	var vector = new openfl_Vector();
	var ` = 0;
	var `1 = array.length;
	while` < `1 {
		var i = `++;
		vector.set(i,array[i]);
	}
	return vector;
};
openfl_Vector.ofArray_Float = function(array) {
	var vector = new openfl_Vector();
	var ` = 0;
	var `1 = array.length;
	while` < `1 {
		var i = `++;
		vector.set(i,array[i]);
	}
	return vector;
};

Note the ` character that trip up the JS parser, causing it to emit the template string error.

On runs that actually work, that code above is not inserted by the Haxe compiler.

Between runs, I do not change anything. I literally run and re-run. The first time it fails, the second it doesn’t.

I’m running the project through the Lime Extension in VSCode.

Hi Bernhard,
I used to POKE 1024 myself at times in my misspent youth. :slight_smile:
I also would guess it is a compiler issue, given the weird tilde ` insertion. I wonder if a macro somewhere is malfunctioning. This is a total shot in the dark but it wouldn’t hurt to check that your .hx files have the right encoding, like UTF8 rather than Western.
Also, posting in the OpenFL forum could get the right eyes on your problem.