haxe
haxe copied to clipboard
Regression : Static variable caching fails in subsequent compilations with compilation server
After the first compilation with "comilation server", subsequent compilations will aways output false.
I'm not sure if this is the expected behavior.
Tested in haxe 5.0.0-alpha.1+765abfa
Main.hx
package;
class Main {
static function main() {
trace(Macros.test("hello world!"));
}
}
Macros.hx
import haxe.macro.Context;
import haxe.macro.Type;
class Macros {
static var cached_t_string : Type;
public static macro function test( e ) {
if (cached_t_string == null) {
cached_t_string = Context.getType("String");
}
var t = Context.follow(Context.typeof(e));
var r = Context.unify(t, cached_t_string);
trace(cached_t_string);
trace(t);
trace(r);
return e;
}
}
build.hxml
-main Main
--js main.js
Starts comilation server:
haxe --server-listen 6000
Building in Cygwin (Because cmd.exe doesn't have touch command)
# First compilation
$ touch Main.hx && haxe --connect 6000 build.hxml
Macros.hx:15: TInst(String,[])
Macros.hx:16: TInst(String,[])
Macros.hx:17: true
# Subsequent compilations
$ touch Main.hx && haxe --connect 6000 build.hxml
Macros.hx:15: TInst(String,[])
Macros.hx:16: TInst(String,[])
Macros.hx:17: false
# Repeated compilations
$ touch Main.hx && haxe --connect 6000 build.hxml
Macros.hx:15: TInst(String,[])
Macros.hx:16: TInst(String,[])
Macros.hx:17: false
It's also weird that if you use VSCODE it always returns true, (maybe my vscode settings aren't right) but FlashDevelop outputs just like above.