summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xcompiler/importer.nim5
-rwxr-xr-xcompiler/semexprs.nim7
-rw-r--r--tests/compile/titerovl.nim21
-rwxr-xr-xtodo.txt31
4 files changed, 42 insertions, 22 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim
index f96377915..c928e8f3c 100755
--- a/compiler/importer.nim
+++ b/compiler/importer.nim
@@ -11,7 +11,7 @@
 
 import 
   intsets, strutils, os, ast, astalgo, msgs, options, idents, rodread, lookups,
-  semdata, passes
+  semdata, passes, renderer
 
 proc evalImport*(c: PContext, n: PNode): PNode
 proc evalFrom*(c: PContext, n: PNode): PNode
@@ -29,7 +29,8 @@ proc getModuleName*(n: PNode): string =
   of nkSym:
     result = n.sym.name.s
   else:
-    internalError(n.info, "getModuleName")
+    localError(n.info, errGenerated,
+      "invalide module name: '$1'" % renderTree(n))
     result = ""
 
 proc checkModuleName*(n: PNode): string =
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index e1d69c0bc..482489a65 100755
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -589,11 +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 {efInTypeOf, efWantIterator} * flags != {}:
+    # consider 'proc p(): seq[int];  for x in p()' here and
     # for ``type(countup(1,3))``, see ``tests/ttoseq``.
-    result = semOverloadedCall(c, n, nOrig, 
+    result = semOverloadedCall(c, n, nOrig,
       {skProc, skMethod, skConverter, skMacro, skTemplate, skIterator})
   else:
     result = semOverloadedCall(c, n, nOrig, 
diff --git a/tests/compile/titerovl.nim b/tests/compile/titerovl.nim
new file mode 100644
index 000000000..be665b2b7
--- /dev/null
+++ b/tests/compile/titerovl.nim
@@ -0,0 +1,21 @@
+discard """
+  output: '''9
+1
+2
+3
+'''
+"""
+
+# Test the new overloading rules for iterators:
+
+# test that iterator 'p' is preferred:
+proc p(): seq[int] = @[1, 2, 3]
+iterator p(): int = yield 9
+
+for x in p(): echo x
+
+# test that 'q' works in this position:
+proc q(): seq[int] = @[1, 2, 3]
+
+for x in q(): echo x
+
diff --git a/todo.txt b/todo.txt
index 10b044a6d..567437c7f 100755
--- a/todo.txt
+++ b/todo.txt
@@ -53,36 +53,27 @@ Concurrency
 - use the effect system to for static deadlock prevention
 
 
-GC
-==
-
-- precise stack marking; embrace C++ code generation for that
-- marker procs for Boehm GC
-- implement 'mixed' GC mode
-
-
 version 0.9.XX
 ==============
 
-- implement the "snoopResult" pragma; no, make a strutils with string append
-  semantics instead ...
-- implement "closure tuple consists of a single 'ref'" optimization
 - object branch transitions can't work with the current 'reset'; add a 'reset'
   with an additional parameter --> re-evaluate this issue after constructors
   have been added
-- allow implicit forward declarations of procs via a pragma (so that the
-  wrappers can deactivate it)
 - fix destructors; don't work yet when used as expression
 - document nimdoc properly finally
 - make 'clamp' a magic for the range stuff
-- 'const' objects including case objects
-- mocking support with ``tyProxy`` that does: fallback for ``.`` operator
 
 
 Not essential for 1.0.0
 =======================
 
-- investigate the implicit items/pairs issue
+- 'const' objects including case objects
+- mocking support with ``tyProxy`` that does: fallback for ``.`` operator
+- allow implicit forward declarations of procs via a pragma (so that the
+  wrappers can deactivate it)
+- implement the "snoopResult" pragma; no, make a strutils with string append
+  semantics instead ...
+- implement "closure tuple consists of a single 'ref'" optimization
 - optimize method dispatchers
 - ``with proc `+`(x, y: T): T`` for generic code
 - new feature: ``distinct T with operations``
@@ -95,6 +86,14 @@ Not essential for 1.0.0
 - implement closures that support nesting of *procs* > 1
 
 
+GC
+==
+
+- precise stack marking; embrace C++ code generation for that
+- marker procs for Boehm GC
+- implement 'mixed' GC mode
+
+
 Optimizations
 =============