Allow fibers as map keys.

This commit is contained in:
Bob Nystrom
2015-05-03 11:12:17 -07:00
parent fcf4197139
commit 3f06553f7f
10 changed files with 60 additions and 20 deletions
+1 -1
View File
@@ -1 +1 @@
var result = {}.containsKey([]) // expect runtime error: Key must be a value type.
var result = {}.containsKey([]) // expect runtime error: Key must be a value type or fiber.
+7 -3
View File
@@ -1,3 +1,5 @@
var fiber = new Fiber {}
var map = {
null: "null value",
true: "true value",
@@ -6,7 +8,8 @@ var map = {
1.2: "1 point 2",
List: "list class",
"null": "string value",
(1..3): "1 to 3"
(1..3): "1 to 3",
fiber: "fiber"
}
IO.print(map[null]) // expect: null value
@@ -17,8 +20,9 @@ IO.print(map[1.2]) // expect: 1 point 2
IO.print(map[List]) // expect: list class
IO.print(map["null"]) // expect: string value
IO.print(map[1..3]) // expect: 1 to 3
IO.print(map[fiber]) // expect: fiber
IO.print(map.count) // expect: 8
IO.print(map.count) // expect: 9
// Use the same keys (but sometimes different objects) to ensure keys have the
// right equality semantics.
@@ -40,4 +44,4 @@ IO.print(map[List]) // expect: new list class
IO.print(map["null"]) // expect: new string value
IO.print(map[1..3]) // expect: new 1 to 3
IO.print(map.count) // expect: 8
IO.print(map.count) // expect: 9
+1 -1
View File
@@ -1 +1 @@
var result = {}.remove([]) // expect runtime error: Key must be a value type.
var result = {}.remove([]) // expect runtime error: Key must be a value type or fiber.
+1 -1
View File
@@ -1 +1 @@
var result = {}[[]] // expect runtime error: Key must be a value type.
var result = {}[[]] // expect runtime error: Key must be a value type or fiber.
@@ -1 +1 @@
var result = {}[[]] = "value" // expect runtime error: Key must be a value type.
var result = {}[[]] = "value" // expect runtime error: Key must be a value type or fiber.