Bug 13284 – [dmd 2.066-rc2] Cannot match shared classes at receive
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-11T13:15:00Z
Last change time
2014-08-21T18:22:14Z
Keywords
pull
Assigned to
nobody
Creator
NCrashed
Comments
Comment #0 by NCrashed — 2014-08-11T13:15:39Z
Now cannot match shared classes at receive callbacks (will fallback to Variant case):
```
import std.stdio;
import std.concurrency;
import core.time;
shared class A {}
void thread()
{
while(true)
{
receiveTimeout(dur!"msecs"(1000),
(shared(A) a) { writeln("Got a!"); return; }
, (Variant v) { assert(false, "Unknown message!"); });
}
}
void main()
{
auto tid = spawn(&thread);
auto a = new shared A();
tid.send(a);
}
```
Platform: 3.15.8-200.fc20.x86_64
dmd: DMD64 D Compiler v2.066.0-rc2
Comment #1 by k.hara.pg — 2014-08-11T15:03:08Z
With 2.055 - 2.065 and git-head, the code produces same result:
[email protected](14): Unknown message!
Which dmd version had produced "Got a!" message?
Comment #2 by NCrashed — 2014-08-11T15:24:08Z
My fault, I've truncated important part while reducing:
```
import std.stdio;
import std.concurrency;
import core.time;
import core.thread;
synchronized class A {}
void thread(Tid parent)
{
bool stop = false;
try
{
while(!stop)
{
receiveTimeout(dur!"msecs"(1000),
(shared A a)
{
writeln("Got a!");
parent.send(true);
stop = true;
}
, (Variant v) { assert(false, "Unhandled message!"); });
}
} catch(Throwable th)
{
writeln(th.toString);
parent.send(true);
}
}
void main()
{
auto tid = spawn(&thread, thisTid);
auto a = new shared A();
tid.send(a);
receiveOnly!bool();
}
```
The code is printing "Got a!" on 2.065 and fails on 2.066-rc2.
Comment #3 by NCrashed — 2014-08-11T15:26:55Z
Note: if main terminates, than the "Unknown message!" assertion is called. The parent termination exception is caught by Variant one.