www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7644] New: [tdpl] receive( (OwnerTerminated) {} ); fails to compile

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7644

           Summary: [tdpl] receive( (OwnerTerminated) {} ); fails to
                    compile
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: peter.alexander.au gmail.com



04:51:48 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 04 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7644


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



10:57:36 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7644


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au





 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) { } ); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 05 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7644


Walter Bright <bugzilla digitalmars.com> changed:

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



11:15:00 PST ---
Since this is now the way the language is supposed to work, I'm going to close
this as not a bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 05 2012