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

disallow taking closures of `@:extern` static methods (closes #4277)

Simon Krajewski 10 жил өмнө
parent
commit
f86d4d315f

+ 12 - 0
tests/unit/src/unit/issues/Issue4277.hx

@@ -0,0 +1,12 @@
+package unit.issues;
+
+class Issue4277 extends Test {
+	function test() {
+		t(unit.TestType.typeError(fancyInlineMethod));
+	}
+
+	@:extern private inline static function fancyInlineMethod(y:Int = 3):Int {
+		var x = 5;
+		return x + (x += x) - y;
+	}
+}

+ 3 - 0
typer.ml

@@ -1056,6 +1056,9 @@ let rec acc_get ctx g p =
 					e_def
 				| TAnon a ->
 					begin match !(a.a_status) with
+						| Statics {cl_extern = false} when Meta.has Meta.Extern f.cf_meta ->
+							display_error ctx "Cannot create closure on @:extern inline method" p;
+							e_def
 						| Statics c when chk_class c -> wrap_extern c
 						| _ -> e_def
 					end