iterable[T] (#17196)
* fix failing test toSeq in manual which now works * changelog * reject proc fn(a: iterable) * add iterable to spec * remove MCS/UFCS limitation that now works
This commit is contained in:
parent
a5b30c94c2
commit
ceadf54d76
18 changed files with 254 additions and 40 deletions
|
|
@ -62,7 +62,7 @@ proc pickBestCandidate(c: PContext, headSymbol: PNode,
|
|||
best, alt: var TCandidate,
|
||||
errors: var CandidateErrors,
|
||||
diagnosticsFlag: bool,
|
||||
errorsEnabled: bool) =
|
||||
errorsEnabled: bool, flags: TExprFlags) =
|
||||
var o: TOverloadIter
|
||||
var sym = initOverloadIter(o, c, headSymbol)
|
||||
var scope = o.lastOverloadScope
|
||||
|
|
@ -95,7 +95,11 @@ proc pickBestCandidate(c: PContext, headSymbol: PNode,
|
|||
matches(c, n, orig, z)
|
||||
if z.state == csMatch:
|
||||
# little hack so that iterators are preferred over everything else:
|
||||
if sym.kind == skIterator: inc(z.exactMatches, 200)
|
||||
if sym.kind == skIterator:
|
||||
if not (efWantIterator notin flags and efWantIterable in flags):
|
||||
inc(z.exactMatches, 200)
|
||||
else:
|
||||
dec(z.exactMatches, 200)
|
||||
case best.state
|
||||
of csEmpty, csNoMatch: best = z
|
||||
of csMatch:
|
||||
|
|
@ -356,7 +360,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
|
|||
template pickBest(headSymbol) =
|
||||
pickBestCandidate(c, headSymbol, n, orig, initialBinding,
|
||||
filter, result, alt, errors, efExplain in flags,
|
||||
errorsEnabled)
|
||||
errorsEnabled, flags)
|
||||
pickBest(f)
|
||||
|
||||
let overloadsState = result.state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue