Skip to content

Commit

Permalink
vercte/dictionaries: Always Cast Keys to Strings (#1644)
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkPool-SP authored Aug 10, 2024
1 parent 23e5c1a commit 5499be0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions extensions/vercte/dictionaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@

dict_get({ KEY, DICT }) {
if (!dictionaries.get(DICT)) return "null";
KEY = Scratch.Cast.toString(KEY);
let dict = dictionaries.get(DICT);
let value = dict.get(KEY);
if (
Expand All @@ -180,6 +181,7 @@
dict_property_defined({ KEY, DICT }) {
if (!dictionaries.get(DICT)) return false;
let dict = dictionaries.get(DICT);
KEY = Scratch.Cast.toString(KEY);
return dict.get(KEY) === undefined ? false : true;
}

Expand All @@ -194,6 +196,7 @@
dictionaries.set(DICT, new Map());
}
let dict = dictionaries.get(DICT);
KEY = Scratch.Cast.toString(KEY);
dict.set(KEY, VAL);
}

Expand All @@ -202,6 +205,7 @@
dictionaries.set(DICT, new Map());
}
let dict = dictionaries.get(DICT);
KEY = Scratch.Cast.toString(KEY);
if (isNaN(+dict.get(KEY))) dict.set(KEY, 0);
dict.set(KEY, dict.get(KEY) + BY);
}
Expand All @@ -212,6 +216,7 @@

dict_delete_key({ KEY, DICT }) {
if (dictionaries.has(DICT)) {
KEY = Scratch.Cast.toString(KEY);
dictionaries.get(DICT).delete(KEY);
}
}
Expand Down

0 comments on commit 5499be0

Please sign in to comment.