From 9483606d5bc074b5c820c3ca8b73c9507139c48a Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 28 Nov 2012 08:03:25 +0100 Subject: [PATCH] bugfix: implicit items/pairs work better --- compiler/semexprs.nim | 7 ++++--- tests/compile/tcolonisproc.nim | 12 ++++++++++++ todo.txt | 1 - 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 tests/compile/tcolonisproc.nim diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index e1d69c0bc..cf0e8f4dd 100755 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -589,9 +589,10 @@ proc semStaticExpr(c: PContext, n: PNode): PNode = proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode, flags: TExprFlags): PNode = - if efWantIterator in flags: - result = semOverloadedCall(c, n, nOrig, {skIterator}) - elif efInTypeOf in flags: + if flags*{efInTypeOf, efWantIterator} != {}: + # consider: 'for x in pReturningArray()' --> we don't want the restriction + # to 'skIterator' anymore; skIterator is preferred in sigmatch already for + # typeof support. # for ``type(countup(1,3))``, see ``tests/ttoseq``. result = semOverloadedCall(c, n, nOrig, {skProc, skMethod, skConverter, skMacro, skTemplate, skIterator}) diff --git a/tests/compile/tcolonisproc.nim b/tests/compile/tcolonisproc.nim new file mode 100644 index 000000000..e55587dfc --- /dev/null +++ b/tests/compile/tcolonisproc.nim @@ -0,0 +1,12 @@ + +proc p(a, b: int, c: proc ()) = + c() + + +p(1, 3): + echo 1 + echo 3 + +p(1, 1, proc() = + echo 1 + echo 2) diff --git a/todo.txt b/todo.txt index 10b044a6d..79b3cb529 100755 --- a/todo.txt +++ b/todo.txt @@ -82,7 +82,6 @@ version 0.9.XX Not essential for 1.0.0 ======================= -- investigate the implicit items/pairs issue - optimize method dispatchers - ``with proc `+`(x, y: T): T`` for generic code - new feature: ``distinct T with operations``