about summary refs log tree commit diff stats
path: root/lib/quickjs
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-02-22 19:31:57 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-02 18:12:24 +0100
commit3bce5ee06cf475bf60c8fd65cae556fb708f88ea (patch)
tree2bf238b1920feca58467e9bd5444520824a4e142 /lib/quickjs
parent994ecade79fced9e21e2794f86b0a34858bd027c (diff)
downloadchawan-3bce5ee06cf475bf60c8fd65cae556fb708f88ea.tar.gz
Fix Map hash bug
- `map_hash_key` must generate the same key for JS_INT and JS_FLOAT64
   with the same value
- add test cases in tests/test_builtin.js
Diffstat (limited to 'lib/quickjs')
-rw-r--r--lib/quickjs/quickjs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 4afbf78b..927f97d2 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -47071,7 +47071,7 @@ static uint32_t map_hash_key(JSContext *ctx, JSValueConst key)
         h = (uintptr_t)JS_VALUE_GET_PTR(key) * 3163;
         break;
     case JS_TAG_INT:
-        d = JS_VALUE_GET_INT(key) * 3163;
+        d = JS_VALUE_GET_INT(key);
         goto hash_float64;
     case JS_TAG_FLOAT64:
         d = JS_VALUE_GET_FLOAT64(key);
@@ -47081,7 +47081,7 @@ static uint32_t map_hash_key(JSContext *ctx, JSValueConst key)
     hash_float64:
         u.d = d;
         h = (u.u32[0] ^ u.u32[1]) * 3163;
-        break;
+        return h ^= JS_TAG_FLOAT64;
     default:
         h = 0; /* XXX: bignum support */
         break;
5'>155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244