summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-05-04 13:21:36 +0200
committerAraq <rumpf_a@web.de>2013-05-04 13:21:36 +0200
commitaf441e607f0da1f76d9f3a67f80d14f23c87b6c9 (patch)
tree459f93b19f48e5c96a02988d58dc386fa8c5c626 /compiler
parent3aa36a85680d85e063c9b1f776300bada69cb79f (diff)
downloadNim-af441e607f0da1f76d9f3a67f80d14f23c87b6c9.tar.gz
fixes #117
Diffstat (limited to 'compiler')
-rw-r--r--compiler/sem.nim4
-rw-r--r--compiler/semexprs.nim17
2 files changed, 15 insertions, 6 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim
index cd332ad90..92b25b1ba 100644
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -72,6 +72,10 @@ proc commonType*(x, y: PType): PType =
   elif b.kind in {tyExpr, tyNil}: result = x
   elif a.kind == tyStmt: result = a
   elif b.kind == tyStmt: result = b
+  elif a.kind == tyTypeDesc:
+    # turn any concrete typedesc into the abstract typedesc type
+    if a.sons == nil: result = a
+    else: result = newType(tyTypeDesc, a.owner)
   elif b.kind in {tyArray, tyArrayConstr, tySet, tySequence} and 
       a.kind == b.kind:
     # check for seq[empty] vs. seq[int]
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 71e44aa43..2ac603920 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -402,10 +402,10 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
       indexType = idx.typ
       x = x.sons[1]
     
-    addSon(result, semExprWithType(c, x))
-    var typ = skipTypes(result.sons[0].typ, {tyGenericInst, tyVar, tyOrdinal})
-    # turn any concrete typedesc into the absract typedesc type
-    if typ.kind == tyTypeDesc: typ.sons = nil
+    let yy = semExprWithType(c, x)
+    var typ = yy.typ
+    addSon(result, yy)
+    #var typ = skipTypes(result.sons[0].typ, {tyGenericInst, tyVar, tyOrdinal})
     for i in countup(1, sonsLen(n) - 1): 
       x = n.sons[i]
       if x.kind == nkExprColonExpr and sonsLen(x) == 2: 
@@ -415,10 +415,15 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
           localError(x.info, errInvalidOrderInArrayConstructor)
         x = x.sons[1]
       
-      n.sons[i] = semExprWithType(c, x, flags*{efAllowDestructor})
-      addSon(result, fitNode(c, typ, n.sons[i]))
+      let xx = semExprWithType(c, x, flags*{efAllowDestructor})
+      result.add xx
+      typ = commonType(typ, xx.typ)
+      #n.sons[i] = semExprWithType(c, x, flags*{efAllowDestructor})
+      #addSon(result, fitNode(c, typ, n.sons[i]))
       inc(lastIndex)
     addSonSkipIntLit(result.typ, typ)
+    for i in 0 .. <result.len:
+      result.sons[i] = fitNode(c, typ, result.sons[i])
   result.typ.sons[0] = makeRangeType(c, 0, sonsLen(result) - 1, n.info)
 
 proc fixAbstractType(c: PContext, n: PNode) =