www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8813] New: Cannot define delegate with const/immutable/shared/inout attributes

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

           Summary: Cannot define delegate with
                    const/immutable/shared/inout attributes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: zan77137 nifty.com



This code doesn't work:
-----------------------
void main()
{
    auto dg = delegate() const { }; // NG
}
-----------------------

And, I do not know whether a cause is the same as this problem... This code
doesn't work, too.
-----------------------
import std.traits;
void main()
{
    static assert(is(FunctionTypeOf!(void delegate() const) == const)); // NG

    alias void delegate() const DG; // OK
    static assert(is(FunctionTypeOf!DG == const)); // OK
}
-----------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 13 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8813





 This code doesn't work:
 -----------------------
 void main()
 {
     auto dg = delegate() const { }; // NG
 }
 -----------------------
In current, the semantics about qualified nested function (==lambda literal) is not defined in language spec. Compiler assumes that the frame pointer of nested function is always mutable.
 And, I do not know whether a cause is the same as this problem... This code
 doesn't work, too.
 -----------------------
 import std.traits;
 void main()
 {
     static assert(is(FunctionTypeOf!(void delegate() const) == const)); // NG
 
     alias void delegate() const DG; // OK
     static assert(is(FunctionTypeOf!DG == const)); // OK
 }
 -----------------------
This is a parser bug and a rest of issue 4838. I've separated it to bug 8822. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2012