-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Broken overload resolution between proc and iterator for iterable #22098
Copy link
Copy link
Closed
Description
Description
The following code compiles and runs fine unless the proc is uncommented. If it is, the error is: Error: undeclared identifier: 'it'. Until the RFC#397 is implemented, the proc shouldn't even affect this code, because currently it works only when the resulting seq is followed by implicit items.
from std/sequtils import toSeq
template moopIt[T](iter: iterable[T]; expr: untyped): untyped =
iterator internal(): auto {.gensym.} =
for it {.inject.} in iter:
yield expr
internal()
iterator splat(s: string): string = (for i in @["X", "Y", "Z"]: yield i)
#proc splat(s: string): seq[string] = @["A", "B", "C"]
assert splat("").moopIt(it[0]).toSeq() == @['X', 'Y', 'Z']Nim Version
Nim Compiler Version 1.9.3 [Linux: amd64]
Compiled at 2023-06-14
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 20dfdba
active boot switches: -d:release
Current Output
No response
Expected Output
* proc doesn't affect resolution, as it doesn't fit itself
* iterator given precedence when resolving `iterable`
Possible Solution
No response
Additional Information
Possibly relevant:
#19206
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels