bugfix: better implict 'items' support
This commit is contained in:
parent
0d19de18cc
commit
0ef08e49e7
4 changed files with 42 additions and 22 deletions
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
intsets, strutils, os, ast, astalgo, msgs, options, idents, rodread, lookups,
|
intsets, strutils, os, ast, astalgo, msgs, options, idents, rodread, lookups,
|
||||||
semdata, passes
|
semdata, passes, renderer
|
||||||
|
|
||||||
proc evalImport*(c: PContext, n: PNode): PNode
|
proc evalImport*(c: PContext, n: PNode): PNode
|
||||||
proc evalFrom*(c: PContext, n: PNode): PNode
|
proc evalFrom*(c: PContext, n: PNode): PNode
|
||||||
|
|
@ -29,7 +29,8 @@ proc getModuleName*(n: PNode): string =
|
||||||
of nkSym:
|
of nkSym:
|
||||||
result = n.sym.name.s
|
result = n.sym.name.s
|
||||||
else:
|
else:
|
||||||
internalError(n.info, "getModuleName")
|
localError(n.info, errGenerated,
|
||||||
|
"invalide module name: '$1'" % renderTree(n))
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
proc checkModuleName*(n: PNode): string =
|
proc checkModuleName*(n: PNode): string =
|
||||||
|
|
|
||||||
|
|
@ -589,9 +589,8 @@ proc semStaticExpr(c: PContext, n: PNode): PNode =
|
||||||
|
|
||||||
proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
|
proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
|
||||||
flags: TExprFlags): PNode =
|
flags: TExprFlags): PNode =
|
||||||
if efWantIterator in flags:
|
if {efInTypeOf, efWantIterator} * flags != {}:
|
||||||
result = semOverloadedCall(c, n, nOrig, {skIterator})
|
# consider 'proc p(): seq[int]; for x in p()' here and
|
||||||
elif efInTypeOf in flags:
|
|
||||||
# for ``type(countup(1,3))``, see ``tests/ttoseq``.
|
# for ``type(countup(1,3))``, see ``tests/ttoseq``.
|
||||||
result = semOverloadedCall(c, n, nOrig,
|
result = semOverloadedCall(c, n, nOrig,
|
||||||
{skProc, skMethod, skConverter, skMacro, skTemplate, skIterator})
|
{skProc, skMethod, skConverter, skMacro, skTemplate, skIterator})
|
||||||
|
|
|
||||||
21
tests/compile/titerovl.nim
Normal file
21
tests/compile/titerovl.nim
Normal 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
|
||||||
|
|
||||||
31
todo.txt
31
todo.txt
|
|
@ -53,36 +53,27 @@ Concurrency
|
||||||
- use the effect system to for static deadlock prevention
|
- 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
|
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'
|
- object branch transitions can't work with the current 'reset'; add a 'reset'
|
||||||
with an additional parameter --> re-evaluate this issue after constructors
|
with an additional parameter --> re-evaluate this issue after constructors
|
||||||
have been added
|
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
|
- fix destructors; don't work yet when used as expression
|
||||||
- document nimdoc properly finally
|
- document nimdoc properly finally
|
||||||
- make 'clamp' a magic for the range stuff
|
- 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
|
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
|
- optimize method dispatchers
|
||||||
- ``with proc `+`(x, y: T): T`` for generic code
|
- ``with proc `+`(x, y: T): T`` for generic code
|
||||||
- new feature: ``distinct T with operations``
|
- new feature: ``distinct T with operations``
|
||||||
|
|
@ -95,6 +86,14 @@ Not essential for 1.0.0
|
||||||
- implement closures that support nesting of *procs* > 1
|
- 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
|
Optimizations
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue