Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup error positions #11630

Merged
merged 3 commits into from
Apr 18, 2024
Merged

Cleanup error positions #11630

merged 3 commits into from
Apr 18, 2024

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Apr 5, 2024

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

@skial skial mentioned this pull request Apr 9, 2024
1 task
@kLabz kLabz merged commit db842bf into development Apr 18, 2024
99 checks passed
@kLabz kLabz deleted the cleanup_error_positions branch May 28, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant