summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2013-12-30 17:07:49 +0200
committerZahary Karadjov <zahary@gmail.com>2013-12-30 17:07:49 +0200
commitaf7c3251cd2b349e9d423a0c5871f37703122dfd (patch)
tree0e3f70717355bebeafc17aae5e2ca2365ae8b689 /compiler
parent7e24cf26dec34a85d7551946f546f32e30b27f42 (diff)
downloadNim-af7c3251cd2b349e9d423a0c5871f37703122dfd.tar.gz
properly remove intLiterals from proc signatures; fixes trettypeinference
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semtypinst.nim18
1 files changed, 13 insertions, 5 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index 0c185b09a..029bf6c8c 100644
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -229,15 +229,13 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
   rawAddSon(result, newbody)
   checkPartialConstructedType(cl.info, newbody)
 
-proc normalizeProcType(t: PType) =
+proc eraseVoidParams(t: PType) =
   if t.sons[0] != nil and t.sons[0].kind == tyEmpty:
     t.sons[0] = nil
   
   for i in 1 .. <t.sonsLen:
+    # don't touch any memory unless necessary
     if t.sons[i].kind == tyEmpty:
-      # the nested loops are here in order to avoid
-      # touching any memory and callign setLen unless
-      # it's really necessary
       var pos = i
       for j in i+1 .. <t.sonsLen:
         if t.sons[j].kind != tyEmpty:
@@ -248,6 +246,15 @@ proc normalizeProcType(t: PType) =
       setLen t.n.sons, pos
       return
 
+proc skipIntLiteralParams(t: PType) =
+  for i in 0 .. <t.sonsLen:
+    let p = t.sons[i]
+    if p == nil: continue
+    let skipped = p.skipIntLit
+    if skipped != p:
+      t.sons[i] = skipped
+      if i > 0: t.n.sons[i].sym.typ = skipped
+
 proc propagateFieldFlags(t: PType, n: PNode) =
   # This is meant for objects and tuples
   # The type must be fully instantiated!
@@ -320,7 +327,8 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
       of tyObject, tyTuple:
         propagateFieldFlags(result, result.n)
       of tyProc:
-        normalizeProcType(result)
+        eraseVoidParams(result)
+        skipIntLiteralParams(result)
       else: discard
 
 proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,