www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10597] New: opDollar not callable in static constext

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: monarchdodra gmail.com


--- Comment #0 from monarchdodra gmail.com 2013-07-10 08:49:46 PDT ---
Discussed here:
http://forum.dlang.org/thread/ddktjwsavfeiahblvrit forum.dlang.org

//----
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: -------
Jul 10 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10597


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
            Version|D1 & D2                     |D2


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-07-10 19:46:29 PDT ---
(opDollar is D2 only feature.)

https://github.com/D-Programming-Language/dmd/pull/2331

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10597



--- Comment #2 from github-bugzilla puremagic.com 2013-07-11 15:32:47 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/4dfcc215b87ea5f1db8dce85dbba97992938e067
fix Issue 10597 - opDollar not callable in static context

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 11 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10597


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

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


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