Skip to content

Commit d6ff4a2

Browse files
gh-162: Make KEYIN reject invalid types for key.
1 parent 5d2b228 commit d6ff4a2

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/builtins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7285,6 +7285,9 @@ static Value builtin_values(Interpreter* interp, Value* args, int argc, Expr** a
72857285
// KEYIN(key, map):INT - returns 1 if map contains key (type+value)
72867286
static Value builtin_keyin(Interpreter* interp, Value* args, int argc, Expr** arg_nodes, Env* env, int line, int col) {
72877287
(void)arg_nodes; (void)env; (void)argc;
7288+
if (args[0].type != VAL_INT && args[0].type != VAL_FLT && args[0].type != VAL_STR) {
7289+
RUNTIME_ERROR(interp, "KEYIN expects INT, FLT or STR as first argument", line, col);
7290+
}
72887291
if (args[1].type != VAL_MAP) RUNTIME_ERROR(interp, "KEYIN expects MAP as second argument", line, col);
72897292
int found = 0;
72907293
Value res = value_map_get(args[1], args[0], &found);

0 commit comments

Comments
 (0)