diff --git a/src/optimization/inline.ml b/src/optimization/inline.ml index 727c0648a66..f9101167dd8 100644 --- a/src/optimization/inline.ml +++ b/src/optimization/inline.ml @@ -700,6 +700,7 @@ let rec type_inline ctx cf f ethis params tret config p ?(self_calling_closure=f typing_error "Could not inline `this` outside of an instance context" po ) | TVar (v,eo) -> + if has_var_flag v VStatic then typing_error "Inline functions cannot have static locals" v.v_pos; { e with eexpr = TVar ((state#declare v).i_subst,opt (map false false) eo)} | TReturn eo when not state#in_local_fun -> if not term then begin diff --git a/tests/misc/projects/Issue11725/Main.hx b/tests/misc/projects/Issue11725/Main.hx new file mode 100644 index 00000000000..308c279b2f2 --- /dev/null +++ b/tests/misc/projects/Issue11725/Main.hx @@ -0,0 +1,6 @@ +function main() foo(); + +inline function foo() { + static var count = 5; + trace(--count); +} \ No newline at end of file diff --git a/tests/misc/projects/Issue11725/compile-fail.hxml b/tests/misc/projects/Issue11725/compile-fail.hxml new file mode 100644 index 00000000000..b30a755894b --- /dev/null +++ b/tests/misc/projects/Issue11725/compile-fail.hxml @@ -0,0 +1,2 @@ +--main Main +--interp \ No newline at end of file diff --git a/tests/misc/projects/Issue11725/compile-fail.hxml.stderr b/tests/misc/projects/Issue11725/compile-fail.hxml.stderr new file mode 100644 index 00000000000..327d99785f1 --- /dev/null +++ b/tests/misc/projects/Issue11725/compile-fail.hxml.stderr @@ -0,0 +1 @@ +Main.hx:4: characters 13-18 : Inline functions cannot have static locals \ No newline at end of file