[Issue 7198] New: Delegate literals with nameless arguments fail to infer a type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 2 05:07:55 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7198
Summary: Delegate literals with nameless arguments fail to
infer a type
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: r.sagitario at gmx.de
--- Comment #0 from Rainer Schuetze <r.sagitario at gmx.de> 2012-01-02 05:07:52 PST ---
Maybe this is an expected side-effect of more magic with delegate type
inference, but the latest dmd version from github causes errors with this code:
module test;
class Widget {}
void main()
{
auto dg0 = delegate void(Widget w) { }; // OK
auto dg1 = delegate void(Widget) { }; // error
void delegate(Widget) dg2 = delegate void(Widget) { }; //OK
void delegate(Widget) dg3;
dg3 = delegate void(Widget) { foo(); }; //error
}
test.d(8): Error: cannot infer type from ambiguous function literal
__dgliteral2
test.d(8): Error: __dgliteral2 has no value
test.d(11): Error: __dgliteral6 has no value
This compiles with dmd 2.057.
I guess the trouble is that the delegate argument "Widget" is interpreted as a
parameter name, not the type. Using "int" instead of "Widget" compiles.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list