fix #1050
This commit is contained in:
parent
aa69a8a09f
commit
1d5ecc0dea
2 changed files with 17 additions and 3 deletions
|
|
@ -229,7 +229,7 @@ proc semConv(c: PContext, n: PNode): PNode =
|
||||||
return n
|
return n
|
||||||
|
|
||||||
result = newNodeI(nkConv, n.info)
|
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)
|
maybeLiftType(targetType, c, n[0].info)
|
||||||
result.addSon copyTree(n.sons[0])
|
result.addSon copyTree(n.sons[0])
|
||||||
var op = semExprWithType(c, n.sons[1])
|
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)
|
if tfNoSideEffect notin t.flags: incl(c.p.owner.flags, sfSideEffect)
|
||||||
elif t != nil and t.kind == tyTypeDesc:
|
elif t != nil and t.kind == tyTypeDesc:
|
||||||
if n.len == 1: return semObjConstr(c, n, flags)
|
if n.len == 1: return semObjConstr(c, n, flags)
|
||||||
let destType = t.skipTypes({tyTypeDesc, tyGenericInst})
|
|
||||||
return semConv(c, n)
|
return semConv(c, n)
|
||||||
else:
|
else:
|
||||||
result = overloadedCallOpr(c, n)
|
result = overloadedCallOpr(c, n)
|
||||||
|
|
@ -928,7 +927,6 @@ proc readTypeParameter(c: PContext, typ: PType,
|
||||||
let ty = if typ.kind == tyGenericInst: typ.skipGenericAlias
|
let ty = if typ.kind == tyGenericInst: typ.skipGenericAlias
|
||||||
else: (internalAssert(typ.kind == tyCompositeTypeClass);
|
else: (internalAssert(typ.kind == tyCompositeTypeClass);
|
||||||
typ.sons[1].skipGenericAlias)
|
typ.sons[1].skipGenericAlias)
|
||||||
#debug ty
|
|
||||||
let tbody = ty.sons[0]
|
let tbody = ty.sons[0]
|
||||||
for s in countup(0, tbody.len-2):
|
for s in countup(0, tbody.len-2):
|
||||||
let tParam = tbody.sons[s]
|
let tParam = tbody.sons[s]
|
||||||
|
|
|
||||||
16
tests/generics/t1050.nim
Normal file
16
tests/generics/t1050.nim
Normal file
|
|
@ -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)
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue