Thread overview
[Issue 18934] std.concurrency receive throws assertion failure is message is a struct of struct
Jun 02, 2018
Russel Winder
[Issue 18934] std.concurrency receive throws assertion failure if message is a struct of struct
Jun 02, 2018
Russel Winder
Jun 02, 2018
Russel Winder
[Issue 18934] std.concurrency receive throws assertion failure if message is a struct containing const data
June 02, 2018
https://issues.dlang.org/show_bug.cgi?id=18934

Russel Winder <russel@winder.org.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.cocurrency receive      |std.concurrency receive
                   |throws assertion failure is |throws assertion failure is
                   |message is a struct of      |message is a struct of
                   |struct                      |struct

--
June 02, 2018
https://issues.dlang.org/show_bug.cgi?id=18934

Russel Winder <russel@winder.org.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.concurrency receive     |std.concurrency receive
                   |throws assertion failure is |throws assertion failure if
                   |message is a struct of      |message is a struct of
                   |struct                      |struct

--
June 02, 2018
https://issues.dlang.org/show_bug.cgi?id=18934

--- Comment #1 from Russel Winder <russel@winder.org.uk> ---
Created attachment 1699
  --> https://issues.dlang.org/attachment.cgi?id=1699&action=edit
Code exhibiting the error

--
June 04, 2018
https://issues.dlang.org/show_bug.cgi?id=18934

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com
           Assignee|nobody@puremagic.com        |schveiguy@yahoo.com

--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> ---
The issue comes from std.variant.Variant checking the wrong thing when it comes to constancy.

A smaller test case:

import std.variant;
import std.stdio;

struct S
{
    const int x;
}
void main()
{
    Variant v = S(1);
    writeln(v.get!S); // error
}

The issue is with the check inside std.variant to see if you can copy the given type to the requested type. The type matches, but the copy would normally fail because you can't overwrite const data.

However, in the case of v.get!S, it's a move and not a copy. The check should be on moving the data, not copying. I have tested a fix, will submit a PR.

--
June 04, 2018
https://issues.dlang.org/show_bug.cgi?id=18934

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> ---
PR: https://github.com/dlang/phobos/pull/6544

--
June 04, 2018
https://issues.dlang.org/show_bug.cgi?id=18934

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.concurrency receive     |std.concurrency receive
                   |throws assertion failure if |throws assertion failure if
                   |message is a struct of      |message is a struct
                   |struct                      |containing const data

--
June 17, 2018
https://issues.dlang.org/show_bug.cgi?id=18934

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/2de6f8da22615e97e016a0e7aecb39f6d5e322d0 Fix issue 18934 - make std.variant support getting types that have const members.

https://github.com/dlang/phobos/commit/cc961daf3220df387a1ae48b8e7c938ce6dee8da Merge pull request #6544 from schveiguy/fix18934

Fix issue 18934 - make std.variant support getting types that have const members

--
June 17, 2018
https://issues.dlang.org/show_bug.cgi?id=18934

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--