[Issue 11261] New: Can't infer types without explicit slice in foreach
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 14 10:54:12 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11261
Summary: Can't infer types without explicit slice in foreach
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: Jesse.K.Phillips+D at gmail.com
--- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D at gmail.com> 2013-10-14 10:54:11 PDT ---
When using a range to proved a key-value tuple, the compiler is unable to infer
the key-value in a foreach when slice is not present (2). Using an array
continues to work (1). This functioned in 2.63.
import std.typecons;
import std.range;
class Container {
alias Tuple!(string, "key", string, "value") Key;
InputRange!Key opSlice() {
// 1 Key[] opSlice() {
Range r;
return inputRangeObject(r);
// 1 return [Key("myKey", "My Value")];
}
private struct Range {
enum empty = false;
auto popFront() {
}
auto front() {
return Key("myKey", "myValue");
}
}
}
void main() {
auto container = new Container();
foreach(k,v; container)
// 2 foreach(k,v; container[])
{ break; }
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list