www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12639] New: Struct-scoped import breaks UFCS


          Issue ID: 12639
           Summary: Struct-scoped import breaks UFCS
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: brian-schott cox.net

struct Foo
    Range opSlice() { return Range(); }
    static struct Range
        int front() { return 10; }
        void popFront() { counter++; }
        bool empty() { return counter >= 10; }
        import std.array;
        int counter;
    int bar;

void main(string[] args)
    import std.stdio;
    import std.array;
    Foo foo;
    auto x = foo[].array();

The above example fails to compile. If you remove the "import std.array;" line
from the Range struct, this works as intended. It also works if you write "auto
x = array(foo[]);"

Apr 24 2014