From a17d45c2c2bf5046b46b5106871e20078be6d075 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 12 Apr 2018 09:19:07 +0200 Subject: [PATCH] fixes #3948 --- compiler/types.nim | 8 +++++++- tests/errmsgs/tnested_empty_seq.nim | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/errmsgs/tnested_empty_seq.nim diff --git a/compiler/types.nim b/compiler/types.nim index 70b4b5aa24..a930779bf5 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1160,9 +1160,13 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, of tySequence, tyOpt: if t.sons[0].kind != tyEmpty: result = typeAllowedAux(marker, t.sons[0], skVar, flags+{taHeap}) + elif kind in {skVar, skLet}: + result = t.sons[0] of tyArray: if t.sons[1].kind != tyEmpty: result = typeAllowedAux(marker, t.sons[1], skVar, flags) + elif kind in {skVar, skLet}: + result = t.sons[1] of tyRef: if kind == skConst: result = t else: result = typeAllowedAux(marker, t.lastSon, skVar, flags+{taHeap}) @@ -1181,7 +1185,9 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, if result != nil: break if result.isNil and t.n != nil: result = typeAllowedNode(marker, t.n, kind, flags) - of tyProxy, tyEmpty: + of tyEmpty: + if kind in {skVar, skLet}: result = t + of tyProxy: # for now same as error node; we say it's a valid type as it should # prevent cascading errors: result = nil diff --git a/tests/errmsgs/tnested_empty_seq.nim b/tests/errmsgs/tnested_empty_seq.nim new file mode 100644 index 0000000000..ffe8bc3eea --- /dev/null +++ b/tests/errmsgs/tnested_empty_seq.nim @@ -0,0 +1,8 @@ +discard """ + errormsg: "invalid type: 'empty' in this context: 'array[0..0, tuple of (string, seq[empty])]' for var" + line: 8 +""" + +# bug #3948 + +var headers=[("headers", @[])]