www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1196] New: regression: "cannot alias an expression"

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

           Summary: regression: "cannot alias an expression"
           Product: D
           Version: 1.013
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thomas-dloop kuehne.cn


This is an interresting case because small - and seemingly unrelated changes - 
can cause the message to vanish:















compile/t/tuple_21_B.d(14): alias dstress.compile.t.tuple_21_B.removeSpace!(" 
Hello you !",6).removeSpace cannot alias an expression "Hello you !"


succeeds

test cases:
http://dstress.kuehne.cn/nocompile/t/template_21_A.d
http://dstress.kuehne.cn/nocompile/t/template_21_B.d
http://dstress.kuehne.cn/run/template_12.d


-- 
Apr 27 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1196


bugzilla digitalmars.com changed:

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





Both examples fail when I try it with the same error message. The error message
is correct - an alias cannot be made of an expression (in this case, a string
literal). A working example would be:

template removeSpace(char[] s, int x = 0)
{
    static if (s[0] == ' '){
       const char[] removeSpace = removeSpace!(s[1..$], x+1);
    }else{
       const char[] removeSpace = s;
    }
}

struct Tuple(A...)
{
    alias A Tuple;
}

static assert("Hello you !" == removeSpace!("       Hello you !"));


-- 
May 08 2007