HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.03k stars 648 forks source link

Cleanup error positions #11630

Closed kLabz closed 2 months ago

kLabz commented 3 months ago

Fixes hxb's unbound type parameter warnings' position which was displayed as (unknown) in non-pretty message reporting modes. Not adding a test because those warnings should not happen so the test would start failing when we fix the underlying issue..

The actual fix here is using pmin = 0; pmax = 0 instead of pmin = -1; pmax = -1 in hxb writer, but this PR also:

Before:

(unknown) : Warning : (WUnboundTypeParameter) Unbound type parameter foo.T

After:

src/Main.hx:1: character 1 : Warning : (WUnboundTypeParameter) Unbound type parameter foo.T

I'm still not sure how to handle "fake positions" in non-pretty message reporting modes, but that's not a new issue and should be addressed separately. For reference, this is about this:

❯ haxe user-defined-define-json-fail.hxml -D message.reporting=indent
(unknown) : Uncaught exception Could not read file define.jsno
  /opt/haxe/std/haxe/macro/Compiler.hx:393: characters 11-39 : Called from here
  (unknown) : Called from here
❯ haxe user-defined-define-json-fail.hxml -D message.reporting=classic
(unknown) : Uncaught exception Could not read file define.jsno
/opt/haxe/std/haxe/macro/Compiler.hx:393: characters 11-39 : Called from here
(unknown) : Called from here

vs:

❯ haxe user-defined-define-json-fail.hxml -D message.reporting=pretty -D message.no-color
[ERROR] --macro haxe.macro.Compiler.registerDefinesDescriptionFile('define.jsno', 'myapp')

   | Uncaught exception Could not read file define.jsno

    ->  /opt/haxe/std/haxe/macro/Compiler.hx:393: characters 11-39

    393 |   var f = sys.io.File.getContent(path);
        |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        | Called from here

        | Called from here