Browse Source

[macro] run static local transformation

closes #11096
Simon Krajewski 2 năm trước cách đây
mục cha
commit
3b9172dcee
2 tập tin đã thay đổi với 18 bổ sung0 xóa
  1. 1 0
      src/typing/macroContext.ml
  2. 17 0
      tests/unit/src/unit/issues/Issue11096.hx

+ 1 - 0
src/typing/macroContext.ml

@@ -474,6 +474,7 @@ and flush_macro_context mint ctx =
 	mctx.com.Common.modules <- modules;
 	(* we should maybe ensure that all filters in Main are applied. Not urgent atm *)
 	let expr_filters = [
+		"local_statics",Filters.LocalStatic.run mctx;
 		"VarLazifier",VarLazifier.apply mctx.com;
 		"handle_abstract_casts",AbstractCast.handle_abstract_casts mctx;
 		"Exceptions",Exceptions.filter mctx;

+ 17 - 0
tests/unit/src/unit/issues/Issue11096.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+private class Macro {
+	public macro static function foo(_i:Int) {
+		static var i:Int;
+		var r = i;
+		i = _i;
+		return macro $v{"" + r}
+	}
+}
+
+class Issue11096 extends Test {
+	function test() {
+		eq("null", Macro.foo(5));
+		eq("5", Macro.foo(2));
+	}
+}