v9.CheckDefAndScriptSuccess(lines)
enddef
+def Test_for_loop_list_of_lists()
+ # loop variable is final, not const
+ var lines =<< trim END
+ # Filter out all odd numbers in each sublist
+ var list: list<list<number>> = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4]]
+ for i in list
+ filter(i, (_, n: number): bool => n % 2 == 0)
+ endfor
+
+ assert_equal([[], [2], [2], [2, 4]], list)
+ END
+ v9.CheckDefAndScriptSuccess(lines)
+enddef
+
def Test_for_loop_with_closure()
# using the loop variable in a closure results in the last used value
var lines =<< trim END
&& need_type_where(item_type, lhs_type, -1,
where, cctx, FALSE, FALSE) == FAIL)
goto failed;
- var_lvar = reserve_local(cctx, arg, varlen, ASSIGN_CONST,
+ var_lvar = reserve_local(cctx, arg, varlen, ASSIGN_FINAL,
lhs_type);
if (var_lvar == NULL)
// out of memory or used as an argument