diff options
author | Zahary Karadjov <zahary@gmail.com> | 2015-01-02 19:19:18 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2015-01-02 23:58:24 +0200 |
commit | 1d5ecc0deac508e7ebb3bf9df01aa34d5025d83d (patch) | |
tree | a8d4566f5a39dc53a3b229226e4ba613463ea066 | |
parent | aa69a8a09f990f485e4ae7058b15067c70e70e28 (diff) | |
download | Nim-1d5ecc0deac508e7ebb3bf9df01aa34d5025d83d.tar.gz |
fix #1050
-rw-r--r-- | compiler/semexprs.nim | 4 | ||||
-rw-r--r-- | tests/generics/t1050.nim | 16 |
2 files changed, 17 insertions, 3 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 89110a479..68921a15a 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -229,7 +229,7 @@ proc semConv(c: PContext, n: PNode): PNode = return n result = newNodeI(nkConv, n.info) - var targetType = semTypeNode(c, n.sons[0], nil) + var targetType = semTypeNode(c, n.sons[0], nil).skipTypes({tyTypeDesc}) maybeLiftType(targetType, c, n[0].info) result.addSon copyTree(n.sons[0]) var op = semExprWithType(c, n.sons[1]) @@ -780,7 +780,6 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode = if tfNoSideEffect notin t.flags: incl(c.p.owner.flags, sfSideEffect) elif t != nil and t.kind == tyTypeDesc: if n.len == 1: return semObjConstr(c, n, flags) - let destType = t.skipTypes({tyTypeDesc, tyGenericInst}) return semConv(c, n) else: result = overloadedCallOpr(c, n) @@ -928,7 +927,6 @@ proc readTypeParameter(c: PContext, typ: PType, let ty = if typ.kind == tyGenericInst: typ.skipGenericAlias else: (internalAssert(typ.kind == tyCompositeTypeClass); typ.sons[1].skipGenericAlias) - #debug ty let tbody = ty.sons[0] for s in countup(0, tbody.len-2): let tParam = tbody.sons[s] diff --git a/tests/generics/t1050.nim b/tests/generics/t1050.nim new file mode 100644 index 000000000..a6f9a2482 --- /dev/null +++ b/tests/generics/t1050.nim @@ -0,0 +1,16 @@ +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) + |