Skip to content

Commit 8046a0e

Browse files
gh-143: INV writes back pointers.
1 parent 8a79cae commit 8046a0e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/builtins.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6885,9 +6885,9 @@ static Value builtin_round(Interpreter* interp, Value* args, int argc, Expr** ar
68856885
return value_flt(rs / factor);
68866886
}
68876887

6888-
// INV (1/x)
6888+
// INV (map inversion)
68896889
static Value builtin_inv(Interpreter* interp, Value* args, int argc, Expr** arg_nodes, Env* env, int line, int col) {
6890-
(void)arg_nodes; (void)env;
6890+
(void)argc;
68916891
(void)interp; (void)line; (void)col;
68926892
if (args[0].type == VAL_MAP) {
68936893
// Map inversion: values become keys, keys become values
@@ -6914,6 +6914,10 @@ static Value builtin_inv(Interpreter* interp, Value* args, int argc, Expr** arg_
69146914
// Insert inverted pair: new_key = value, new_value = key
69156915
value_map_set(&out, val, key);
69166916
}
6917+
if (!writeback_ptr_range(interp, arg_nodes, env, 0, 1, out, "INV", line, col)) {
6918+
value_free(out);
6919+
return value_null();
6920+
}
69176921
return out;
69186922
}
69196923

0 commit comments

Comments
 (0)