[Issue 13805] Nested struct initialization error
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Dec 1 09:17:07 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13805
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|DMD |Phobos
Hardware|x86 |All
OS|Windows |All
--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> ---
This would be a Phobos bug in GroupByImpl struct.
static if (isForwardRange!Range)
{
private Range _prev;
private void savePrev() { _prev = r.save; }
private @property ElementType!Range prev() { return _prev.front; }
}
else
{
private ElementType!Range _prev;
private void savePrev() { _prev = r.front; }
private alias prev = _prev;
}
this(Range _r)
{
r = _r;
if (!empty)
{
// Check reflexivity if predicate is claimed to be an equivalence
// relation.
assert(!equivRelation || pred(r.front, r.front),
"predicate " ~ pred.stringof ~ " is claimed to be "~
"equivalence relation yet isn't reflexive");
savePrev(); // <---- here
}
}
As error message says, the _prev field is not correctly initialized inside
constructor. Indeed, it's assigned in savePrev member function, but compiler
cannot handle the assignment as the initialization.
--
More information about the Digitalmars-d-bugs
mailing list