Nim/tests/metatype/typeclassinference.nim
Zahary Karadjov 9a3963f51b fix #959
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.
2014-09-04 23:50:00 +03:00

21 lines
366 B
Nim

discard """
errormsg: "type mismatch: got (string) but expected 'ptr'"
line: 20
"""
import typetraits
type
Vec[N: static[int]; T] = distinct array[N, T]
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