Comment #0 by peter.alexander.au — 2012-03-04T04:51:48Z
The code snippet on this page no longer compiles in 2.059
http://www.informit.com/articles/article.aspx?p=1609144&seqNum=8
Minimal example:
--------------------------------
void foo() {
import std.concurrency;
receive( (OwnerTerminated) { } );
}
--------------------------------
std/concurrency.d(529): Error: cannot have parameter of type void
std/concurrency.d(529): Error: variable std.concurrency.receive!(void).receive._param_0 voids have no value
The problem appears to be with lambdas with unnamed user-defined parameters:
--------------------------------
class Foo {}
auto a = (Foo) {}; // error
auto b = (Foo f) {}; // ok
--------------------------------
If this is intentional, it wasn't mentioned as a breaking change in the 2.059 changelog.
Comment #1 by bugzilla — 2012-03-04T10:57:36Z
With:
class Foo {}
auto a = (Foo) {}; // error
I get with 2.058 and 2.059:
Error: cannot infer type from ambiguous function literal __lambda2
That's different from what you say you're getting. It's also correct, as the type of parameter Foo cannot be inferred.
Comment #2 by peter.alexander.au — 2012-03-04T14:14:19Z
(In reply to comment #1)
> With:
>
> class Foo {}
> auto a = (Foo) {}; // error
>
> I get with 2.058 and 2.059:
>
> Error: cannot infer type from ambiguous function literal __lambda2
>
> That's different from what you say you're getting. It's also correct, as the
> type of parameter Foo cannot be inferred.
That's the same as what I get. The error message in the post relates to the OwnerTerminated code snippet above it.
I don't understand what you mean with the type inference for the Foo parameter. The type is Foo.
Is this an errata for TDPL?
Comment #3 by clugdbug — 2012-03-05T04:56:28Z
(In reply to comment #2)
> (In reply to comment #1)
> > With:
> >
> > class Foo {}
> > auto a = (Foo) {}; // error
> >
> > I get with 2.058 and 2.059:
> >
> > Error: cannot infer type from ambiguous function literal __lambda2
> >
> > That's different from what you say you're getting. It's also correct, as the
> > type of parameter Foo cannot be inferred.
>
> That's the same as what I get. The error message in the post relates to the
> OwnerTerminated code snippet above it.
>
> I don't understand what you mean with the type inference for the Foo parameter.
> The type is Foo.
The change in 2.058 was that given:
auto a = (x) { ... };
x is a parameter, of type to be inferred.
Previously, it was assumed to be a type.
> Is this an errata for TDPL?
I believe so. Should be rewritten to something like:
void foo() {
import std.concurrency;
receive( (OwnerTerminated x) { } );
}
Comment #4 by bugzilla — 2012-03-05T11:15:00Z
Since this is now the way the language is supposed to work, I'm going to close this as not a bug.