D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16074 - std.concurrency receive wont work
Summary: std.concurrency receive wont work
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: Emily82
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-25 15:59 UTC by Emily82
Modified: 2016-05-25 17:43 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Emily82 2016-05-25 15:59:37 UTC
Hi guys, i noticed a strange compiler error when trying to use the std.concurrency receive.

import std.stdio;
import std.concurrency;
import core.thread;

void workerFunc() {
        receive(
                 (int message) {
                        writeln("Message ", message);
                 }
        );
}


void main() {
        auto worker = spawn(&workerFunc);
	worker.send(10);
        thread_joinAll();
}

Trying to compile i got error "Error: function expected before (), not module receive of type void"

Note: if i use receiveTimeout instead of receive there is no issue. I'm using dmd version 2.071.0
Comment 1 Steven Schveighoffer 2016-05-25 16:57:15 UTC
You have a module named receive. Perhaps this module?

Why does receiveTimeout work? because you didn't name your module that :)

You can work around by renaming the import:

import std.concurrency: spawn, con_recv = receive;

or use fully qualified name:

std.concurrency.receive( ...
Comment 2 Steven Schveighoffer 2016-05-25 16:58:38 UTC
(In reply to Steven Schveighoffer from comment #1)
> You can work around by renaming the import:
> 
> import std.concurrency: spawn, con_recv = receive;

Alternatively:

import con = std.concurrency;

...

con.receive( ...

...

con.spawn( ...
Comment 3 Emily82 2016-05-25 17:20:52 UTC
Ehehee yes, you are right, i made a noob report, sorry guys.
Comment 4 Steven Schveighoffer 2016-05-25 17:43:05 UTC
No worries! Welcome to D :)