Skip to content

Commit

Permalink
error if we inline a static local
Browse files Browse the repository at this point in the history
closes #11725
  • Loading branch information
Simn authored and kLabz committed Jul 18, 2024
1 parent 3b5b3cc commit 2d44cce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/optimization/inline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 raise_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
Expand Down
6 changes: 6 additions & 0 deletions tests/misc/projects/Issue11725/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function main() foo();

inline function foo() {
static var count = 5;
trace(--count);
}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue11725/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main Main
--interp
1 change: 1 addition & 0 deletions tests/misc/projects/Issue11725/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main.hx:4: characters 13-18 : Inline functions cannot have static locals

0 comments on commit 2d44cce

Please sign in to comment.