summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/ccgcalls.nim15
-rw-r--r--tests/run/tgenericprocvar.nim19
-rwxr-xr-xtodo.txt2
3 files changed, 30 insertions, 6 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim
index f2fa6a280..17139f055 100644
--- a/compiler/ccgcalls.nim
+++ b/compiler/ccgcalls.nim
@@ -20,7 +20,8 @@ proc hasNoInit(call: PNode): bool {.inline.} =
 
 proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc, pl: PRope) =
   var pl = pl
-  var typ = ri.sons[0].typ # getUniqueType() is too expensive here!
+  # getUniqueType() is too expensive here:
+  var typ = skipTypes(ri.sons[0].typ, abstractInst)
   if typ.sons[0] != nil:
     if isInvalidReturnType(typ.sons[0]):
       if sonsLen(ri) > 1: app(pl, ", ")
@@ -124,7 +125,8 @@ proc genPrefixCall(p: BProc, le, ri: PNode, d: var TLoc) =
   # this is a hotspot in the compiler
   initLocExpr(p, ri.sons[0], op)
   var pl = con(op.r, "(")
-  var typ = ri.sons[0].typ # getUniqueType() is too expensive here!
+  # getUniqueType() is too expensive here:
+  var typ = skipTypes(ri.sons[0].typ, abstractInst)
   assert(typ.kind == tyProc)
   var length = sonsLen(ri)
   for i in countup(1, length - 1):
@@ -150,7 +152,8 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
   var op: TLoc
   initLocExpr(p, ri.sons[0], op)
   var pl: PRope
-  var typ = ri.sons[0].typ
+  
+  var typ = skipTypes(ri.sons[0].typ, abstractInst)
   assert(typ.kind == tyProc)
   var length = sonsLen(ri)
   for i in countup(1, length - 1):
@@ -201,7 +204,8 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =
   var op, a: TLoc
   initLocExpr(p, ri.sons[0], op)
   var pl: PRope = nil
-  var typ = ri.sons[0].typ # getUniqueType() is too expensive here!
+  # getUniqueType() is too expensive here:
+  var typ = skipTypes(ri.sons[0].typ, abstractInst)
   assert(typ.kind == tyProc)
   var length = sonsLen(ri)
   assert(sonsLen(typ) == sonsLen(typ.n))
@@ -228,7 +232,8 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) =
   var op, a: TLoc
   initLocExpr(p, ri.sons[0], op)
   var pl = toRope"["
-  var typ = ri.sons[0].typ # getUniqueType() is too expensive here!
+  # getUniqueType() is too expensive here:
+  var typ = skipTypes(ri.sons[0].typ, abstractInst)
   assert(typ.kind == tyProc)
   var length = sonsLen(ri)
   assert(sonsLen(typ) == sonsLen(typ.n))
diff --git a/tests/run/tgenericprocvar.nim b/tests/run/tgenericprocvar.nim
index 7fdc58ca4..088909d58 100644
--- a/tests/run/tgenericprocvar.nim
+++ b/tests/run/tgenericprocvar.nim
@@ -1,5 +1,5 @@
 discard """
-  output: "0false"
+  output: "0false12"
 """
 
 # Test multiple generic instantiation of generic proc vars:
@@ -17,3 +17,20 @@ proc threadProcWrapper[TMsg]() =
 threadProcWrapper[int]()
 threadProcWrapper[bool]()
 
+type
+  TFilterProc[T,D] = proc (item: T, env:D): bool
+
+proc filter[T,D](data: seq[T], env:D, pred: TFilterProc[T,D]): seq[T] =
+  result = @[]
+  for e in data:
+    if pred(e, env): result.add(e)
+
+proc predTest(item: int, value: int): Bool =
+  return item <= value
+
+proc test(data: seq[int], value: int): seq[int] =
+  return filter(data, value, predTest)
+
+for x in items(test(@[1,2,3], 2)):
+  stdout.write(x)
+
diff --git a/todo.txt b/todo.txt
index 68a3b93b0..31b8c7268 100755
--- a/todo.txt
+++ b/todo.txt
@@ -1,6 +1,8 @@
 version 0.9.0
 =============
 
+- fix the installer
+- implement 'gorge'
 - make templates hygienic by default: try to gensym() everything in the 'block'
   of a template
 - ``bind`` for overloaded symbols does not work apparently