digitalmars.D.bugs - [Issue 6782] New: inout-correct range is not iterable using foreach with type deduction inside non-inout function
- d-bugmail puremagic.com (54/54) Oct 07 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6782
- d-bugmail puremagic.com (10/10) Oct 07 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6782
- d-bugmail puremagic.com (12/12) Oct 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6782
http://d.puremagic.com/issues/show_bug.cgi?id=6782 Summary: inout-correct range is not iterable using foreach with type deduction inside non-inout function Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: schveiguy yahoo.com --- Comment #0 from Steven Schveighoffer <schveiguy yahoo.com> 2011-10-07 13:07:02 PDT --- This should compile: struct range { int *ptr; property inout(int)* front() inout { return ptr; } property bool empty() const { return ptr is null; } void popFront() { ptr = null; } } void main() { int x = 5; auto r = range(&x); foreach(p; r) // line 24 { } } bug.d(24): Error: variable bug.main.p inout variables can only be declared inside inout functions bug.d(24): Error: cannot implicitly convert expression (__r1.front()) of type int* to inout(int)* The range foreach rewrite somehow gets inout into the resulting type of r.front, where it should really be the resulting wild type (in this case int*) Changing the foreach loop to: foreach(int *p; r) { } compiles. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 07 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6782 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch --- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2011-10-07 16:07:18 PDT --- https://github.com/D-Programming-Language/dmd/pull/439 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 07 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6782 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED --- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2011-10-08 16:26:38 PDT --- https://github.com/D-Programming-Language/dmd/commit/28b39dece1fe6a4d5c82c7accd04ba380855dd11 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 08 2011