www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2856] New: static opIndex does not compile for a templated struct/class

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

           Summary: static opIndex does not compile for a templated
                    struct/class
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: sandford jhu.edu


Static opIndex functions result in compile time errors for templated structs
and classes. Using a typedef, fixes the issue. static opCall and generic static
functions don't appear to be affected.
Test case:
import std.stdio;

struct foo    { static void opIndex(int i) { writefln("foo"); } }
struct bar(T) { static void opIndex(int i) { writefln("bar"); } }

int main(char[][] args) {

    foo[1];
    //bar!(float)[1];      // Error (# = __LINE__)
    typedef bar!(float) B; 
    B[1];                  // Okay

    return 0;
}
main.d:#: Error: struct bar must be an array or pointer type, not void
main.d:#: Error: [i] has no effect in expression (struct bar[1])


-- 
Apr 18 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2856


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
           Platform|x86                         |All
         OS/Version|Windows                     |All


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2011-10-15 04:07:40 PDT ---
https://github.com/D-Programming-Language/dmd/pull/453

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 15 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2856


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2011-11-16
00:26:48 PST ---
https://github.com/D-Programming-Language/dmd/commit/1e0aa894292a969cb7149d2bdb76d7576e291e79

https://github.com/D-Programming-Language/dmd/commit/8857ba8f88a5e9a7f39dba6bcd98bc2de9820cd4

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