mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
bugfix: better implict 'items' support
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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,
|
||||
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
=============
|
||||
|
||||
|
||||
Reference in New Issue
Block a user