http://d.puremagic.com/issues/show_bug.cgi?id=10597

           Summary: opDollar not callable in static constext
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from [email protected] 2013-07-10 08:49:46 PDT ---
Discussed here:
http://forum.dlang.org/thread/[email protected]

//----
struct R
{
    void opIndex(int);
    int opDollar();
}
R r;

void foo()
{
    static assert(is(typeof(r[0]))); //ok
    static assert(is(typeof(r[$]))); //ok
}

static assert(is(typeof(r[0]))); //ok
static assert(is(typeof(r[$]))); //fails (!)

struct S
{
    void foo()
    {
        static assert(is(typeof(r[0]))); //ok
        static assert(is(typeof(r[$]))); //ok
    }

    static assert(is(typeof(r[0]))); //ok
    static assert(is(typeof(r[$]))); //fails (!)
}
//----

Calling opDollar in a "static context" fails. Apparently, it would appear that
opDollar is looking for some sort of "this" or context pointer.

If opDollar is defined as static, or enum, then the above code works.

The error message is kind of weird too:
main.d(15): Error: static assert  (is(typeof(r.opIndex((int __dollar =
r.opDollar();
 , __dollar))))) is false

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

Reply via email to