haxe icon indicating copy to clipboard operation
haxe copied to clipboard

`Sys.programPath()` fails on Interp target: `[0] Instance prototype not found: haxe.macro.Error`

Open miriti opened this issue 2 years ago • 2 comments

Haxe v4.2.5

Main.hx:

function main()
  trace(Sys.programPath());
haxe --run Main

Results in:

[0] Instance prototype not found: haxe.macro.Error

I'm getting the same result on both Mac (M1) and Linux (amd64).

miriti avatar Apr 20 '23 20:04 miriti

This is quite funny, apparently it tries to report the Main class, but doesn't find one because there isn't one. The actual error is Module Main does not define type Main. So there are two problems here:

  1. It has to account for module-level main
  2. It should not fail while trying to locate haxe.macro.Error

Simn avatar Apr 20 '23 20:04 Simn

Indeed. I've wrapped this code in a class and now it works!

class Main {
  public static function main()
    trace(Sys.programPath());
}

miriti avatar Apr 20 '23 20:04 miriti