immutable(ubyte)[] to receive

FeepingCreature feepingcreature at gmail.com
Thu Jan 20 11:24:18 UTC 2022


On Thursday, 20 January 2022 at 09:38:55 UTC, Alexey wrote:
> Maybe someone knows why it doesn't work?
> ```
> import std.concurrency;
> import std.stdio: write, writeln, writef, writefln;
> import std.variant : Variant;
> import std.process : thisThreadID;
>
> alias Buffer = immutable(ubyte)[];
>
> void pros2(string name)
>     {
>      receive(
>
>             (immutable(Buffer[]) h){
>                 writeln(h);
>                 ownerTid.send(123);
>             }
>      );
>  }
> void main()
> {
>
>     Buffer[] t ;
>     t ~= cast(Buffer)"sdfsdfsdf";
>     t ~= cast(Buffer)"sdfsdfsdf";
>     immutable(Buffer[]) ti = cast(immutable)t;
>
>
>     auto tid2 = spawn(&pros2, "hello");
>     send(tid2, ti);
>     receive(
>        (int h){writeln(h);}
>     );
>  }
> ```

It's a Phobos bug.

```
import std.variant;
void main() {
     alias A = immutable(ubyte)[];
     auto a = Variant(immutable(A[]).init);
     assert(a.convertsTo!(immutable(A[])));
}
```

File a bug report, please?


More information about the Digitalmars-d mailing list