Implement typed dictionaries
This commit is contained in:
parent
906a4e9db9
commit
9853a69144
86 changed files with 3071 additions and 193 deletions
|
|
@ -0,0 +1,3 @@
|
|||
func test():
|
||||
for key: int in { "a": 1 }:
|
||||
print(key)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Cannot include a value of type "String" as "int".
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var differently: Dictionary[float, float] = { 1.0: 0.0 }
|
||||
var typed: Dictionary[int, int] = differently
|
||||
print('not ok')
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Cannot assign a value of type Dictionary[float, float] to variable "typed" with specified type Dictionary[int, int].
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
func test():
|
||||
const dict: Dictionary[int, int] = { "Hello": "World" }
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Cannot include a value of type "String" as "int".
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
func test():
|
||||
var unconvertible := 1
|
||||
var typed: Dictionary[Object, Object] = { unconvertible: unconvertible }
|
||||
print('not ok')
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Cannot have a key of type "int" in a dictionary of type "Dictionary[Object, Object]".
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
func expect_typed(typed: Dictionary[int, int]):
|
||||
print(typed.size())
|
||||
|
||||
func test():
|
||||
var differently: Dictionary[float, float] = { 1.0: 0.0 }
|
||||
expect_typed(differently)
|
||||
print('not ok')
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_ANALYZER_ERROR
|
||||
Invalid argument for "expect_typed()" function: argument 1 should be "Dictionary[int, int]" but is "Dictionary[float, float]".
|
||||
Loading…
Add table
Add a link
Reference in a new issue