April 27, 2007 [Issue 1196] New: regression: "cannot alias an expression" | ||||
---|---|---|---|---|
| ||||
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: # template removeSpace(char[] s, int x = 0) { # static if (s[0] == ' '){ # alias removeSpace!(s[1..$], x+1) removeSpace; # }else{ # alias s removeSpace; # } # } # # struct Tuple(A...) { # alias A Tuple; # } # static assert("Hello you !" == removeSpace!(" Hello you !")); 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 !" # static assert("Hello you !" == removeSpace!(" Hello you !").Tuple[0]); 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 -- |
May 08, 2007 [Issue 1196] regression: "cannot alias an expression" | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1196 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #1 from bugzilla@digitalmars.com 2007-05-08 16:29 ------- 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 !")); -- |
Copyright © 1999-2021 by the D Language Foundation