prevent unhashable panic

This commit is contained in:
2023-03-14 00:07:18 +00:00
parent cf25d392be
commit 406eafb8a4
7 changed files with 53 additions and 23 deletions

View File

@@ -42,6 +42,10 @@ func init() {
switch y := v.(type) {
case ArArray:
if len(y) == 2 {
keytype := typeof(y[0])
if keytype == "array" || keytype == "map" {
return nil, ArErr{TYPE: "TypeError", message: "Cannot use unhashable value as key: " + keytype, EXISTS: true}
}
newmap[y[0]] = y[1]
continue
}