From 1b58076a1876e001b38868d5981f3c66428c055c Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Wed, 31 Jul 2024 09:05:50 +0200 Subject: [PATCH 1/3] [tests] add failing test demonstrating the issue --- tests/misc/projects/Issue11740/Baz.hx | 6 ++++++ tests/misc/projects/Issue11740/Macro.macro.hx | 17 +++++++++++++++++ tests/misc/projects/Issue11740/Main.hx | 5 +++++ tests/misc/projects/Issue11740/compile1.hxml | 2 ++ .../projects/Issue11740/compile1.hxml.stdout | 2 ++ tests/misc/projects/Issue11740/compile2.hxml | 3 +++ tests/misc/projects/Issue11740/foo/Foo.hx | 4 ++++ 7 files changed, 39 insertions(+) create mode 100644 tests/misc/projects/Issue11740/Baz.hx create mode 100644 tests/misc/projects/Issue11740/Macro.macro.hx create mode 100644 tests/misc/projects/Issue11740/Main.hx create mode 100644 tests/misc/projects/Issue11740/compile1.hxml create mode 100644 tests/misc/projects/Issue11740/compile1.hxml.stdout create mode 100644 tests/misc/projects/Issue11740/compile2.hxml create mode 100644 tests/misc/projects/Issue11740/foo/Foo.hx diff --git a/tests/misc/projects/Issue11740/Baz.hx b/tests/misc/projects/Issue11740/Baz.hx new file mode 100644 index 00000000000..bf370233bc4 --- /dev/null +++ b/tests/misc/projects/Issue11740/Baz.hx @@ -0,0 +1,6 @@ +import foo.Foo; + +class Baz { + function baz(data:foo.FooData) {} +} + diff --git a/tests/misc/projects/Issue11740/Macro.macro.hx b/tests/misc/projects/Issue11740/Macro.macro.hx new file mode 100644 index 00000000000..803e9371469 --- /dev/null +++ b/tests/misc/projects/Issue11740/Macro.macro.hx @@ -0,0 +1,17 @@ +import haxe.macro.Context; + +class Macro { + public static function build() { + trace("build FooData"); + + Context.defineType({ + pos : Context.currentPos(), + name : "FooData", + pack : ["foo"], + kind : TDClass(), + fields : [], + }); + + return null; + } +} diff --git a/tests/misc/projects/Issue11740/Main.hx b/tests/misc/projects/Issue11740/Main.hx new file mode 100644 index 00000000000..63590c32ad4 --- /dev/null +++ b/tests/misc/projects/Issue11740/Main.hx @@ -0,0 +1,5 @@ +import foo.Foo; + +function main() { + trace(Baz); +} diff --git a/tests/misc/projects/Issue11740/compile1.hxml b/tests/misc/projects/Issue11740/compile1.hxml new file mode 100644 index 00000000000..7d61297e2cb --- /dev/null +++ b/tests/misc/projects/Issue11740/compile1.hxml @@ -0,0 +1,2 @@ +-main Main +--interp diff --git a/tests/misc/projects/Issue11740/compile1.hxml.stdout b/tests/misc/projects/Issue11740/compile1.hxml.stdout new file mode 100644 index 00000000000..513fc838c7d --- /dev/null +++ b/tests/misc/projects/Issue11740/compile1.hxml.stdout @@ -0,0 +1,2 @@ +Macro.macro.hx:5: build FooData +Main.hx:4: Class diff --git a/tests/misc/projects/Issue11740/compile2.hxml b/tests/misc/projects/Issue11740/compile2.hxml new file mode 100644 index 00000000000..660cee52f25 --- /dev/null +++ b/tests/misc/projects/Issue11740/compile2.hxml @@ -0,0 +1,3 @@ +-main Main +Baz +--interp diff --git a/tests/misc/projects/Issue11740/foo/Foo.hx b/tests/misc/projects/Issue11740/foo/Foo.hx new file mode 100644 index 00000000000..4dc77078eb7 --- /dev/null +++ b/tests/misc/projects/Issue11740/foo/Foo.hx @@ -0,0 +1,4 @@ +package foo; + +@:build(Macro.build()) +class Foo {} From d2acdf19fa2b858a9b05b5f4aec3f913bda9cbb9 Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Wed, 31 Jul 2024 09:45:23 +0200 Subject: [PATCH 2/3] Flush between actx.classes loading --- src/compiler/compiler.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/compiler.ml b/src/compiler/compiler.ml index 2c0db1ed8da..d85d6eb0f13 100644 --- a/src/compiler/compiler.ml +++ b/src/compiler/compiler.ml @@ -308,7 +308,10 @@ let do_type ctx mctx actx display_file_dot_path = com.callbacks#run com.error_ext com.callbacks#get_after_init_macros; run_or_diagnose ctx (fun () -> if com.display.dms_kind <> DMNone then DisplayTexpr.check_display_file tctx cs; - List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos)) (List.rev actx.classes); + List.iter (fun cpath -> + ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos); + Typecore.flush_pass tctx.g (PBuildClass:Typecore.typer_pass) "actx.classes" + ) (List.rev actx.classes); Finalization.finalize tctx; ); end with TypeloadParse.DisplayInMacroBlock -> From c88ad6588b6a0e1324c7f5e0ca66762879162cbd Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Wed, 7 Aug 2024 16:37:09 +0200 Subject: [PATCH 3/3] [tests] Update failing test But why was it 3 before? --- tests/misc/projects/Issue11004/build.hxml.stdout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/misc/projects/Issue11004/build.hxml.stdout b/tests/misc/projects/Issue11004/build.hxml.stdout index 800b6c23fee..399b8e53256 100644 --- a/tests/misc/projects/Issue11004/build.hxml.stdout +++ b/tests/misc/projects/Issue11004/build.hxml.stdout @@ -1 +1 @@ -Bar.hx:27: @:storedTypedExpr 3 computed this_ident as: foo.bar \ No newline at end of file +Bar.hx:27: @:storedTypedExpr 1 computed this_ident as: foo.bar