fix: remove fiber support as map keys and revert to value-only key validation
The previous implementation allowed fibers as map keys by assigning each fiber a unique numeric ID for hashing and equality. This was originally added to support a misguided attempt at thread-local storage that was never used. This commit removes the fiber ID field from ObjFiber, the nextFiberId counter from WrenVM, the fiber hashing case in hashObject(), and the IS_FIBER check in validateKey(). The error message for invalid keys is updated from "Key must be a value type or fiber." to "Key must be a value type." and all affected test expectations are updated accordingly.
This commit is contained in:
@@ -1 +1 @@
|
||||
var result = {}.containsKey([]) // expect runtime error: Key must be a value type or fiber.
|
||||
var result = {}.containsKey([]) // expect runtime error: Key must be a value type.
|
||||
|
||||
@@ -8,8 +8,7 @@ var map = {
|
||||
1.2: "1 point 2",
|
||||
List: "list class",
|
||||
"null": "string value",
|
||||
(1..3): "1 to 3",
|
||||
fiber: "fiber"
|
||||
(1..3): "1 to 3"
|
||||
}
|
||||
|
||||
System.print(map[null]) // expect: null value
|
||||
@@ -20,9 +19,8 @@ System.print(map[1.2]) // expect: 1 point 2
|
||||
System.print(map[List]) // expect: list class
|
||||
System.print(map["null"]) // expect: string value
|
||||
System.print(map[1..3]) // expect: 1 to 3
|
||||
System.print(map[fiber]) // expect: fiber
|
||||
|
||||
System.print(map.count) // expect: 9
|
||||
System.print(map.count) // expect: 8
|
||||
|
||||
// Use the same keys (but sometimes different objects) to ensure keys have the
|
||||
// right equality semantics.
|
||||
@@ -44,4 +42,4 @@ System.print(map[List]) // expect: new list class
|
||||
System.print(map["null"]) // expect: new string value
|
||||
System.print(map[1..3]) // expect: new 1 to 3
|
||||
|
||||
System.print(map.count) // expect: 9
|
||||
System.print(map.count) // expect: 8
|
||||
|
||||
@@ -1 +1 @@
|
||||
var result = {}.remove([]) // expect runtime error: Key must be a value type or fiber.
|
||||
var result = {}.remove([]) // expect runtime error: Key must be a value type.
|
||||
|
||||
@@ -1 +1 @@
|
||||
var result = {}[[]] // expect runtime error: Key must be a value type or fiber.
|
||||
var result = {}[[]] // expect runtime error: Key must be a value type.
|
||||
|
||||
@@ -1 +1 @@
|
||||
var result = {}[[]] = "value" // expect runtime error: Key must be a value type or fiber.
|
||||
var result = {}[[]] = "value" // expect runtime error: Key must be a value type.
|
||||
|
||||
Reference in New Issue
Block a user