Summary: static opIndex does not compile for a templated
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: DMD

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) {

    //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])


Reply via email to