Skip to content

Commit

Permalink
Simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed May 18, 2023
1 parent 180506c commit b546c4d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 25 deletions.
33 changes: 10 additions & 23 deletions tests/misc/projects/Issue10374/Main.hx
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
#if macro
import haxe.macro.Context;
#end

class Main {
static function main() {
Test.foo();
test();
}

static macro function test() {
if(try {Context.getType('Test.Sub'); false;} catch(_:Any) true) {
Context.defineModule("Test", [{
pos: Context.currentPos(),
pack: [],
name: 'Sub',
params: [],
meta: [],
kind: TDAlias(macro :String),
fields: []
}, {
pos: (macro moduleField).pos,
pack: [],
name: 'moduleField',
params: [],
meta: [],
kind: TDField(FVar(null, macro null), [AInline, AFinal]),
fields: []
}]);
}
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 {};
}
Expand Down
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 {};
}
}
3 changes: 3 additions & 0 deletions tests/misc/projects/Issue10374/Test.hx
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
class Test {}

function foo() {}

4 changes: 2 additions & 2 deletions tests/misc/projects/Issue10374/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Main.hx:7: characters 3-9 : Cannot add module level fields for module Test
Test.hx:1: character 1 : Previously defined here
Main.hx:9: characters 16-27 : Cannot add module level fields for module Test
Test.hx:3: 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 b546c4d

Please sign in to comment.