fix #1056
This commit is contained in:
parent
1b54c55b7b
commit
b83b1383fb
3 changed files with 31 additions and 2 deletions
|
|
@ -926,7 +926,8 @@ const
|
|||
proc readTypeParameter(c: PContext, typ: PType,
|
||||
paramName: PIdent, info: TLineInfo): PNode =
|
||||
let ty = if typ.kind == tyGenericInst: typ.skipGenericAlias
|
||||
else: (internalAssert(typ.kind == tyCompositeTypeClass); typ.sons[1])
|
||||
else: (internalAssert(typ.kind == tyCompositeTypeClass);
|
||||
typ.sons[1].skipGenericAlias)
|
||||
#debug ty
|
||||
let tbody = ty.sons[0]
|
||||
for s in countup(0, tbody.len-2):
|
||||
|
|
@ -965,6 +966,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
|||
var ty = n.sons[0].typ
|
||||
var f: PSym = nil
|
||||
result = nil
|
||||
|
||||
if isTypeExpr(n.sons[0]) or (ty.kind == tyTypeDesc and ty.base.kind != tyNone):
|
||||
if ty.kind == tyTypeDesc: ty = ty.base
|
||||
ty = ty.skipTypes(tyDotOpTransparent)
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym,
|
|||
result = n
|
||||
styleCheckUse(n.info, s)
|
||||
of skType:
|
||||
if (s.typ != nil) and (s.typ.kind != tyGenericParam):
|
||||
if (s.typ != nil) and
|
||||
(s.typ.flags * {tfGenericTypeParam, tfImplicitTypeParam} == {}):
|
||||
result = newSymNodeTypeDesc(s, n.info)
|
||||
else:
|
||||
result = n
|
||||
|
|
|
|||
26
tests/generics/t1056.nim
Normal file
26
tests/generics/t1056.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
discard """
|
||||
output: '''TMatrix[3, 3, system.int]
|
||||
3
|
||||
3'''
|
||||
"""
|
||||
|
||||
import typetraits
|
||||
|
||||
type
|
||||
TMatrix*[N,M: static[int], T] = object
|
||||
data*: array[0..N*M-1, T]
|
||||
|
||||
TMat2[T] = TMatrix[2,2,T]
|
||||
|
||||
proc echoMatrix(a: TMatrix) =
|
||||
echo a.type.name
|
||||
echo TMatrix.N
|
||||
|
||||
proc echoMat2(a: TMat2) =
|
||||
echo TMat2.M
|
||||
|
||||
var m = TMatrix[3,3,int](data: [1,2,3,4,5,6,7,8,9])
|
||||
|
||||
echoMatrix m
|
||||
echoMat2 m
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue