Fix sigsegv in getTypeImpl for unnamed tuple (#5440)
avoid sigsegv in getTypeImpl for unnamed tuple; fixes #4862
This commit is contained in:
parent
73387e89a0
commit
e2567e2e03
2 changed files with 11 additions and 2 deletions
|
|
@ -218,8 +218,13 @@ proc mapTypeToAstX(t: PType; info: TLineInfo;
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
if inst:
|
if inst:
|
||||||
result = newNodeX(nkTupleTy)
|
result = newNodeX(nkTupleTy)
|
||||||
for s in t.n.sons:
|
# only named tuples have a node, unnamed tuples don't
|
||||||
result.add newIdentDefs(s)
|
if t.n.isNil:
|
||||||
|
for subType in t.sons:
|
||||||
|
result.add mapTypeToAst(subType, info)
|
||||||
|
else:
|
||||||
|
for s in t.n.sons:
|
||||||
|
result.add newIdentDefs(s)
|
||||||
else:
|
else:
|
||||||
result = mapTypeToBracket("tuple", mTuple, t, info)
|
result = mapTypeToBracket("tuple", mTuple, t, info)
|
||||||
of tySet: result = mapTypeToBracket("set", mSet, t, info)
|
of tySet: result = mapTypeToBracket("set", mSet, t, info)
|
||||||
|
|
|
||||||
|
|
@ -120,3 +120,7 @@ test(Tree):
|
||||||
right: ref Tree
|
right: ref Tree
|
||||||
test(proc (a: int, b: Foo[2,float]))
|
test(proc (a: int, b: Foo[2,float]))
|
||||||
test(proc (a: int, b: Foo[2,float]): Bar[3,int])
|
test(proc (a: int, b: Foo[2,float]): Bar[3,int])
|
||||||
|
|
||||||
|
# bug #4862
|
||||||
|
static:
|
||||||
|
discard typedesc[(int, int)].getTypeImpl
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue