summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-05-03 01:05:14 +0200
committerAraq <rumpf_a@web.de>2015-05-03 01:08:52 +0200
commite23857a98bc1f682896910c545eb9eae7ff5225f (patch)
tree84aa8df02d7b0787a9b28b78fb0ad5717f825313 /compiler/semexprs.nim
parent6cb3635ca05cf5a95b3cc0751bb5f99d41a2e074 (diff)
downloadNim-e23857a98bc1f682896910c545eb9eae7ff5225f.tar.gz
fixes #2629, fixes #2641, fixes #2632, fixes #2630
Diffstat (limited to 'compiler/semexprs.nim')
-rw-r--r--compiler/semexprs.nim15
1 files changed, 13 insertions, 2 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 21fc4ec40..cd6ba3753 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -535,7 +535,18 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
       result.sons[i] = fitNode(c, typ, result.sons[i])
   result.typ.sons[0] = makeRangeType(c, 0, sonsLen(result) - 1, n.info)
 
-template fixAbstractType(c: PContext, n: PNode) =
+proc fixAbstractType(c: PContext, n: PNode) =
+  for i in 1 .. < n.len:
+    let it = n.sons[i]
+    # do not get rid of nkHiddenSubConv for OpenArrays, the codegen needs it:
+    if it.kind == nkHiddenSubConv and
+        skipTypes(it.typ, abstractVar).kind notin {tyOpenArray, tyVarargs}:
+      if skipTypes(it.sons[1].typ, abstractVar).kind in
+            {tyNil, tyArrayConstr, tyTuple, tySet}:
+        var s = skipTypes(it.typ, abstractVar)
+        if s.kind != tyExpr:
+          changeType(it.sons[1], s, check=true)
+        n.sons[i] = it.sons[1]
   when false:
     # XXX finally rewrite that crap!
     for i in countup(1, sonsLen(n) - 1):
@@ -2042,7 +2053,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
   of nkEmpty, nkNone, nkCommentStmt:
     discard
   of nkNilLit:
-    result.typ = getSysType(tyNil)
+    if result.typ == nil: result.typ = getSysType(tyNil)
   of nkIntLit:
     if result.typ == nil: setIntLitType(result)
   of nkInt8Lit: