From 5499be00481fe997593935247f1e28499ac17c1a Mon Sep 17 00:00:00 2001 From: SharkPool <139097378+SharkPool-SP@users.noreply.github.com> Date: Fri, 9 Aug 2024 18:36:28 -0700 Subject: [PATCH] vercte/dictionaries: Always Cast Keys to Strings (#1644) --- extensions/vercte/dictionaries.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/vercte/dictionaries.js b/extensions/vercte/dictionaries.js index ad60a2da13..83cedcd972 100644 --- a/extensions/vercte/dictionaries.js +++ b/extensions/vercte/dictionaries.js @@ -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 ( @@ -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; } @@ -194,6 +196,7 @@ dictionaries.set(DICT, new Map()); } let dict = dictionaries.get(DICT); + KEY = Scratch.Cast.toString(KEY); dict.set(KEY, VAL); } @@ -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); } @@ -212,6 +216,7 @@ dict_delete_key({ KEY, DICT }) { if (dictionaries.has(DICT)) { + KEY = Scratch.Cast.toString(KEY); dictionaries.get(DICT).delete(KEY); } }