[Issue 15774] New: cant write import std.range; twice

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Mar 6 05:00:49 PST 2016


https://issues.dlang.org/show_bug.cgi?id=15774

          Issue ID: 15774
           Summary: cant write  import std.range;  twice
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: mephisto at nordhoff-online.de

import std.range;

public struct myRng( E)
{
        import std.range;

public:
        @property E front()
        {
                return 0;
        }
        @property void front( int elem)
        {
        }
        void popFront()
        {
        }
        @property bool empty()
        {
                return true;
        }
        @property auto save()
        {
                return this;
        }
}
static assert( isForwardRange!( myRng!int));

bool check_( SomeThing)( SomeThing fofo) if( isInputRange!SomeThing)
{
        return is( fofo);
}
unittest
{
        auto r = myRng!int();
        assert( r.check_ == false);
        assert( walkLength( r) == 0);
        assert( r.walkLength == 1);   // here the compiler fails
}$ 
$ 
$ 
$ 
$ 
$ dmd --version | fgrep -i dmd
DMD64 D Compiler v2.070.1
$ 
$ 
$ 
$ dmd t.d -lib -unittest
t.d(38): Error: cannot resolve type for r.walkLength(Range)(Range range) if
(isInputRange!Range && !isInfinite!Range)
$ 


cant write import std.range; twice in that situation.

its not okay, because with "mixin template" i have to write it twice sometimes.
(the compiler complains, if i dont write the imports into the mixins. i dont
even know, if that is correct behaviour)

--


More information about the Digitalmars-d-bugs mailing list