Variable declarations using a type class will be subject to type inference similar to the one
already present in type coercions and the return type inference.
This commit is contained in:
Zahary Karadjov 2014-09-04 23:50:00 +03:00
commit 9a3963f51b
3 changed files with 27 additions and 6 deletions

View file

@ -1,3 +1,8 @@
discard """
errormsg: "type mismatch: got (string) but expected 'ptr'"
line: 20
"""
import typetraits
type
@ -8,3 +13,9 @@ var x = Vec([1, 2, 3])
static:
assert x.type.name == "Vec[static[int](3), int]"
var str1: string = "hello, world!"
var ptr1: ptr = addr(str1)
var str2: string = "hello, world!"
var ptr2: ptr = str2