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

Macro defined modules vs direct loading of types using it #11740

Open
wants to merge 3 commits into
base: development
Choose a base branch
from

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Jul 31, 2024

While this looks like a very edge case / weird usage, this actually is easy to trigger in real use case because of diagnostics triggering similar behavior to compile2.hxml.

Not sure yet how to handle that, just pushing the repro for now..

@kLabz
Copy link
Contributor Author

kLabz commented Jul 31, 2024

@Simn any idea how this could be handled?

@Simn
Copy link
Member

Simn commented Jul 31, 2024

Could you describe the actual problem? I can't really make it out from looking at that test.

@kLabz
Copy link
Contributor Author

kLabz commented Jul 31, 2024

Flushing between each actx.classes load seems to do the job, but will have to watch out for new issues..

Edit: only test failure detected so far:

Done running 664 tests with 1 failures
SUMMARY:
projects/Issue11004/build.hxml
-Bar.hx:27: @:storedTypedExpr 3 computed this_ident as: foo.bar
+Bar.hx:27: @:storedTypedExpr 1 computed this_ident as: foo.bar

Might not be a problem, but would need to double check there

@kLabz
Copy link
Contributor Author

kLabz commented Jul 31, 2024

"Normal" typing order:

  • Main
  • foo.Foo
  • => build macro, with defineType
  • Baz
  • => FooData is built

But when adding Baz to actx.classes, we get:

  • Main
  • foo.Foo
  • no flush so no build macro run at this point
  • Baz
  • => FooData is not built yet

@Simn
Copy link
Member

Simn commented Jul 31, 2024

I can't immediately tell what the difference is between referencing Baz on the command line vs. referencing it from Main itself, e.g. via a typedef X = Baz at the bottom.

@kLabz
Copy link
Contributor Author

kLabz commented Jul 31, 2024

Difference is each of those types referenced in command line / display files / main are loaded without flushing there:

List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos)) (List.rev actx.classes);

So build macros don't happen early enough

@kLabz
Copy link
Contributor Author

kLabz commented Jul 31, 2024

vs. referencing it from Main itself, e.g. via a typedef X = Baz at the bottom.

This does trigger the issue too indeed

@Simn
Copy link
Member

Simn commented Jul 31, 2024

Flushing what exactly, and where does that normally occur?

@kLabz
Copy link
Contributor Author

kLabz commented Jul 31, 2024

Flushing what exactly, and where does that normally occur?

Doing a flush_pass tctx.g PBuildClass in between those:

List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos)) (List.rev actx.classes);

@kLabz kLabz marked this pull request as ready for review August 7, 2024 13:31
@kLabz
Copy link
Contributor Author

kLabz commented Aug 7, 2024

I found another way to trigger this issue in a shiro project, basically with haxe build.hxml ParentClass ChildClass (or Json RPC diagnostics with ParentClass.hx and ChildClass.hx open), resulting in:

Loop in class building prevent compiler termination (ParentClass)

I don't have a minimal repro yet to add as test; ideas would be appreciated 😅
(edit: flush does fix that too)

But why was it 3 before?
@kLabz
Copy link
Contributor Author

kLabz commented Dec 2, 2024

@Simn can we merge this? It can happen easily with multi file diagnostics :/

@Simn
Copy link
Member

Simn commented Dec 3, 2024

It's unlikely to be a good fix because it doesn't address the typedef X = Baz case. We can merge it to get the test, but let's keep an issue open for the more general situation. Maybe even a PR that has a failing test case.

@kLabz
Copy link
Contributor Author

kLabz commented Dec 3, 2024

Right. I don't know why I thought the typedef situation was expected

@kLabz
Copy link
Contributor Author

kLabz commented Dec 3, 2024

This also somehow solves an issue I have with compiling some shiro projects (while others on windows don't have the issue), but I'm also getting some X is redefined from X errors which could be related to this PR... so uh might not be a good idea to merge yet.

Edit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants