[Issue 12760] Initializing an object that has "this(Args) inout" causes "discards return value" warning
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun May 18 00:09:12 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12760
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
Component|Phobos |DMD
Hardware|x86_64 |All
Summary|Initializing |Initializing an object that
|std.typecons.Nullable |has "this(Args) inout"
|causes "discards return |causes "discards return
|value" warning |value" warning
OS|Linux |All
Severity|normal |regression
--- Comment #1 from monarchdodra at gmail.com ---
(In reply to sinkuu from comment #0)
> this()
> {
> nullable = 0; // Warning: calling
> ...
> Nullable!int n;
> n = 0; // ok
I'll point out that these are not the same: The first actually calls a
constructor, whereas the second calls opAssign.
In any case, here is a reduced test case:
struct S(T)
{
T i;
this(T j) inout //<-- HERE
{ }
}
struct K
{
S!int nullable;
this(int)
{
nullable = 0;
//Or nullable = S!int(0);
}
}
The issue is the "this" is marked as inout. I'm not quite sure what that
(currently) means, but it's what is triggering the issue.
Re tagging as DMD regressions.
--
More information about the Digitalmars-d-bugs
mailing list