Skip to content

Commit

Permalink
[tests] Add test for 10374
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Feb 7, 2025
1 parent ff746a9 commit 0b3e34d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/misc/projects/Issue10374/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Main {
static function main() {
Test.foo();
test();
}

static macro function test() {
haxe.macro.Context.defineModule("Test", [{
pos: (macro moduleField).pos,
pack: [],
name: 'moduleField',
params: [],
meta: [],
kind: TDField(FVar(null, macro null), [AInline, AFinal]),
fields: []
}]);

return macro {};
}
}
21 changes: 21 additions & 0 deletions tests/misc/projects/Issue10374/Main2.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Main2 {
static function main() {
// Works fine if Test wasn't loaded
// Note that types/fields declared in Test.hx will become unusable
test();
}

static macro function test() {
haxe.macro.Context.defineModule("Test", [{
pos: (macro moduleField).pos,
pack: [],
name: 'moduleField',
params: [],
meta: [],
kind: TDField(FVar(null, macro null), [AInline, AFinal]),
fields: []
}]);

return macro {};
}
}
4 changes: 4 additions & 0 deletions tests/misc/projects/Issue10374/Test.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Test {}

function foo() {}

1 change: 1 addition & 0 deletions tests/misc/projects/Issue10374/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-main Main
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue10374/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Main.hx:4: characters 3-9 : Cannot redefine module Test
Test.hx:1: character 1 : Previously defined here
1 change: 1 addition & 0 deletions tests/misc/projects/Issue10374/compile2.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-main Main2

0 comments on commit 0b3e34d

Please sign in to comment.