| |
| Posted by bb.temp@gmx.com | PermalinkReply |
|
bb.temp@gmx.com
| https://issues.dlang.org/show_bug.cgi?id=4654
bb.temp@gmx.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bb.temp@gmx.com
Resolution|--- |INVALID
--- Comment #2 from bb.temp@gmx.com ---
(In reply to Infiltrator from comment #1)
> The issue is that the opApply delegate takes three ints, so obviously it won't compile if you pass only one. I know that with AAs you can do both foreach(value) and foreach(key,value); but I'm not sure how exactly that's implemented.
>
> Having said that, this bug report does highlight a problem with the error message and it should stay open until it is fixed.
>
> Current (2.068) message:
> Error: cannot infer argument types, expected 3 arguments, not 1
>
> As for what it should be, I don't really have any good suggestions.
No you don't get the point. The problem is that dmd recognizes both InputRange or opApply() as foreach aggregate argument. The OP expected the InpuRange to be used in the first case and opApply in the second:
---
foreach(elem; range) {} // should use front/empty/popFront
foreach(e1, e2, e3; range) {} // should use opApply
---
Actually this issue is invalid because the behavior is specified:
http://dlang.org/statement.html#foreach-with-ranges
> if the aggregate expression is a struct or class object, but the opApply for foreach, or opApplyReverse foreach_reverse do not exist, then iteration over struct and class objects can be done with range primitives
Meaning: if opApply is not present then look for InputRange primitives.
--
|