Thread overview
[Issue 15681] [REG2.067] Nested user type enum not retaining value properly.
Feb 14, 2016
ag0aep6g@gmail.com
Feb 15, 2016
b2.temp@gmx.com
Feb 17, 2016
Kenji Hara
Feb 17, 2016
Kenji Hara
February 14, 2016
https://issues.dlang.org/show_bug.cgi?id=15681

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g@gmail.com
            Summary|Nested user type enum not   |[REG2.067] Nested user type
                   |retaining value properly.   |enum not retaining value
                   |                            |properly.
                 OS|Windows                     |All
           Severity|normal                      |regression

--- Comment #1 from ag0aep6g@gmail.com ---
Reduced a little further:

----
struct A {float value;}

struct S
{
    A[2] values;

    this(float)
    {
        values[0].value = 0;
        values[1].value = 1;
    }
}

void main()
{
    {
        auto s = S(1.0f);
        assert(s.values[0].value == 0); /* passes */
        assert(s.values[1].value == 1); /* passes */
    }
    {
        enum s = S(1.0f);
        assert(s.values[0].value == 0); /* fails */
        assert(s.values[1].value == 1); /* passes */
    }
}
----

Works with 2.066. Fails since 2.067.

--
February 15, 2016
https://issues.dlang.org/show_bug.cgi?id=15681

--- Comment #2 from b2.temp@gmx.com ---
fails as well with `static S s = S(1.0f);
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=15681

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE

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

--
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=15681

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

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

--
February 23, 2016
https://issues.dlang.org/show_bug.cgi?id=15681

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

https://github.com/D-Programming-Language/dmd/commit/1d13794bc84a6af0d13f84a16baf6f881109668e fix Issue 15681 - Nested user type enum not retaining value properly

1. It was a bug in `createBlockDuplicatedArrayLiteral` function. On array literal construction, the element should be copied when the type has value semantics and the CTFE value has sub payload.

2. Also the `createBlockDuplicatedArrayLiteral` callers need to handle the
`elem` argument ownership well.
2a. In `copyLiteral`, it didn't copy the source struct element on block
assignment. 2b. In `recursivelyCreateArrayLiteral`, the
`elemType.defaultInitLiteral(loc)` is not yet CTFE-ed expression. So it should
be interpreted to copy it into CTFE world.

https://github.com/D-Programming-Language/dmd/commit/21c35b077388429de36f6f8d63063d4a6a35facd Merge pull request #5462 from 9rnsr/fix15681

[REG2.067] Issue 15681 - Nested user type enum not retaining value properly

--
February 24, 2016
https://issues.dlang.org/show_bug.cgi?id=15681

--- Comment #6 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/1d13794bc84a6af0d13f84a16baf6f881109668e fix Issue 15681 - Nested user type enum not retaining value properly

https://github.com/D-Programming-Language/dmd/commit/21c35b077388429de36f6f8d63063d4a6a35facd Merge pull request #5462 from 9rnsr/fix15681

--