From 908383e4cab979dcc3ee7a1c1710dd5314984065 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 8 Apr 2013 20:18:33 +0200 Subject: [PATCH] fixes #321 --- compiler/semexprs.nim | 3 ++- tests/run/titerslice.nim | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/run/titerslice.nim diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 962272ec4..bf07f843e 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -996,7 +996,8 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode = checkSonsLen(n, 2) n.sons[0] = makeDeref(n.sons[0]) for i in countup(1, sonsLen(n) - 1): - n.sons[i] = semExprWithType(c, n.sons[i], flags) + n.sons[i] = semExprWithType(c, n.sons[i], + flags*{efInTypeof, efDetermineType}) var indexType = if arr.kind == tyArray: arr.sons[0] else: getSysType(tyInt) var arg = IndexTypesMatch(c, indexType, n.sons[1].typ, n.sons[1]) if arg != nil: diff --git a/tests/run/titerslice.nim b/tests/run/titerslice.nim new file mode 100644 index 000000000..e5d2e14a3 --- /dev/null +++ b/tests/run/titerslice.nim @@ -0,0 +1,9 @@ +discard """ + output: '''2 +3 +4''' +""" + +var t1 = @["1", "2", "3", "4"] +for t in t1[1..3]: + echo t