1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-05 18:13:37 +00:00

Disallow NaN as table/struct key.

Fix bugs and add tests for denormalized tables
and structs.
This commit is contained in:
Calvin Rose
2019-01-28 11:50:33 -05:00
parent c333cbfa55
commit 38a7e4faf1
4 changed files with 23 additions and 13 deletions

View File

@@ -131,6 +131,7 @@ Janet janet_table_remove(JanetTable *t, Janet key) {
/* Put a value into the object */
void janet_table_put(JanetTable *t, Janet key, Janet value) {
if (janet_checktype(key, JANET_NIL)) return;
if (janet_checktype(key, JANET_NUMBER) && isnan(janet_unwrap_number(key))) return;
if (janet_checktype(value, JANET_NIL)) {
janet_table_remove(t, key);
} else {