expressi
expressi copied to clipboard
Infer a type of captured free variable in function body
- Implement
Value::free_variables
- Remove
check_captures
and replace its uses with that above - Use
Value::free_variables
inTypeInfer::transform_with_env
and rollbacknew_env
changes toenv
test code:
let zero = (f, x) -> x;
let succ = n -> (f, x) -> f(n(f, x));
let plus = (m, n) -> m(succ, n); // !
let toint = f -> f(x -> x + 1, 0);
let four = plus(succ(zero), succ(succ(succ(zero))));
toint(four) // 4
- doesn't work!