diff options
author | Fabian Keller <bluenote10@users.noreply.github.com> | 2017-03-02 15:30:19 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-02 15:30:19 +0100 |
commit | e2567e2e03c72929cbdfbf59933b4f35868b9626 (patch) | |
tree | 673b0a263417787b302ce62baf0c0627dff1fd38 | |
parent | 73387e89a09c376e5ca415bc4596281958ec3cae (diff) | |
download | Nim-e2567e2e03c72929cbdfbf59933b4f35868b9626.tar.gz |
Fix sigsegv in getTypeImpl for unnamed tuple (#5440)
avoid sigsegv in getTypeImpl for unnamed tuple; fixes #4862
-rw-r--r-- | compiler/vmdeps.nim | 9 | ||||
-rw-r--r-- | tests/macros/tgettypeinst.nim | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index ebd2f557f..779d6d2a4 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -218,8 +218,13 @@ proc mapTypeToAstX(t: PType; info: TLineInfo; of tyTuple: if inst: result = newNodeX(nkTupleTy) - for s in t.n.sons: - result.add newIdentDefs(s) + # only named tuples have a node, unnamed tuples don't + 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: result = mapTypeToBracket("tuple", mTuple, t, info) of tySet: result = mapTypeToBracket("set", mSet, t, info) diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim index 22e03a119..255eff949 100644 --- a/tests/macros/tgettypeinst.nim +++ b/tests/macros/tgettypeinst.nim @@ -120,3 +120,7 @@ test(Tree): right: ref Tree test(proc (a: int, b: Foo[2,float])) test(proc (a: int, b: Foo[2,float]): Bar[3,int]) + +# bug #4862 +static: + discard typedesc[(int, int)].getTypeImpl |