mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 01:44:37 +00:00
30 lines
361 B
Nim
30 lines
361 B
Nim
discard """
|
|
msg: "int"
|
|
output: "4"
|
|
"""
|
|
|
|
import typetraits
|
|
|
|
type ArrayType[T] = distinct T
|
|
|
|
proc arrayItem(a: ArrayType): auto =
|
|
static: echo(name(type(a).T))
|
|
result = (type(a).T)(4)
|
|
|
|
var arr: ArrayType[int]
|
|
echo arrayItem(arr)
|
|
|
|
# bug #5597
|
|
|
|
template fail() = "what"
|
|
|
|
proc g[T](x: var T) =
|
|
x.fail = 3
|
|
|
|
type
|
|
Obj = object
|
|
fail: int
|
|
|
|
var y: Obj
|
|
g y
|