www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1371] New: Compiler rejects valid delegate.

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

           Summary: Compiler rejects valid delegate.
           Product: D
           Version: 1.019
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: aziz.kerim gmail.com


// The compiler tries to parse this as a struct initializer.
auto foo = { while (doSomething()){} }; // Error: expression expected, not
'while'

There are several workarounds to this.

auto foo = { while (doSomething()){;} }; // Insert a semicolon somewhere.
auto foo = (){ while (doSomething()){} }; // Add a ParameterList.
auto foo = delegate void (){ while (doSomething()){} }; // A full delegate
expression.


-- 
Jul 25 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1371


Daniel919 web.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|1.019                       |2.003





string delegate() dg = { return "dg"; };
//Error: functions cannot return static array invariant char[2u]
//Error: cannot implicitly convert expression (__dgliteral1) of type int
delegate() to const(char)[] delegate()

string delegate() dg = { return cast(string) "dg"; }; //OK
//string delegate() dg = delegate string() { return "dg"; }; //OK
//auto dg = { return "dg".dup; }; //OK


-- 
Aug 14 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1371


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k.hara.pg gmail.com



Follwing still fails in trunk dmd 2.054
(d36b3b12fc4814e59f3a0d680b8700e787b1ceff).

auto foo = { while (doSomething()){} };

Workarounds are as same.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 18 2011