bugfix: better implict 'items' support

This commit is contained in:
Araq
2012-11-28 19:57:41 +01:00
parent 0d19de18cc
commit 0ef08e49e7
4 changed files with 42 additions and 22 deletions

View File

@@ -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 =

View File

@@ -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,

View File

@@ -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

View File

@@ -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
=============