Thread overview
[Issue 12760] Initializing an object that has "this(Args) inout" causes "discards return value" warning
[Issue 12760] Initializing std.typecons.Nullable causes "discards return value" warning
May 18, 2014
sinkuu@aol.jp
May 21, 2014
Vladimir Panteleev
May 22, 2014
Kenji Hara
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12760

sinkuu@aol.jp changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Initializing                |Initializing
                   |std.typecons.Nullable       |std.typecons.Nullable
                   |causes false warning        |causes "discards return
                   |"discards return value"     |value" warning

--
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12760

monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra@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@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.

--
May 21, 2014
https://issues.dlang.org/show_bug.cgi?id=12760

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com

--- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> ---
Introduced in https://github.com/D-Programming-Language/dmd/pull/3432

--
May 22, 2014
https://issues.dlang.org/show_bug.cgi?id=12760

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid

--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/3569

--
May 25, 2014
https://issues.dlang.org/show_bug.cgi?id=12760

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3f3f8cfb49f381e81d3b868cbcaa9bc91ec10d4b
fix Issue 12760 - Initializing an object that has "this(Args) inout" causes
"discards return value" warning

https://github.com/D-Programming-Language/dmd/commit/f4ef69f504db74cd0debaa3aadd5f469440c3013 Merge pull request #3569 from 9rnsr/fix12760

[REG2.066a] Issue 12760 - Initializing an object that has "this(Args) inout" causes "discards return value" warning

--