File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,8 @@ impl VM {
196196 }
197197
198198 // If refs != 1, the vars are prolly used somewhere else so don't clear them
199+ // TODO: This doesn't work and doesn't pass the fourth test in vm_closure.rs, instead we
200+ // should try using weak ptr's
199201 if refs == 1 {
200202 ( & mut * environ. borrow_mut ( ) ) . vars . clear ( ) ;
201203 }
Original file line number Diff line number Diff line change @@ -111,3 +111,27 @@ fn main {
111111 Value :: Number ( 3.0 ) ,
112112 ) ;
113113}
114+
115+ #[ test]
116+ fn vm_test_closure_4 ( ) {
117+ expect_to_return (
118+ r#"
119+ fn closure array {
120+ let x = 5;
121+ let closure = fn {
122+ return x;
123+ };
124+ return closure;
125+ }
126+
127+ fn main {
128+ let arr = [];
129+ let f =closure(arr);
130+
131+ return f();
132+ }
133+ "#
134+ . into ( ) ,
135+ Value :: Number ( 5.0 ) ,
136+ ) ;
137+ }
You can’t perform that action at this time.
0 commit comments