2
0
Эх сурвалжийг харах

[macro] only load module statics if we're looking for the module

closes #10716
Simon Krajewski 3 жил өмнө
parent
commit
6c5c491d31

+ 1 - 1
src/typing/macroContext.ml

@@ -572,7 +572,7 @@ let load_macro' ctx display cpath f p =
 		let mloaded,restore = load_macro_module ctx mpath display p in
 		let cl, meth =
 			try
-				if sub <> None then raise Not_found;
+				if sub <> None || mloaded.m_path <> cpath then raise Not_found;
 				match mloaded.m_statics with
 				| None -> raise Not_found
 				| Some c ->

+ 21 - 0
tests/unit/src/unit/issues/Issue10716.hx

@@ -0,0 +1,21 @@
+package unit.issues;
+
+using unit.issues.Issue10716.Extension;
+
+private class Extension {
+	macro public static function test(x:ExprOf<Int>)
+		return macro $x + $v{1};
+}
+
+class Issue10716 extends unit.Test {
+	function test() {
+		#if !macro
+		eq(11, 10.test());
+		#end
+
+		utest.Assert.pass();
+	}
+}
+
+function test()
+	return 1;