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:
introduces file_pos and fake_pos functions to avoid { null_pos with ... } / manual pos building with pmin/pmax = 0 / -1
updates pretty errors to not display first line of a module when a position points to the whole module; I don't think this could have bad side effects as I can't really see errors which would point at first character (and not a range) of a module and for which printing that first line would be helpful
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
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 ofpmin = -1; pmax = -1
in hxb writer, but this PR also:file_pos
andfake_pos
functions to avoid{ null_pos with ... }
/ manual pos building with pmin/pmax = 0 / -1Before:
After:
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:
vs: