Thread overview |
---|
March 13, 2007 [Issue 1059] New: String literal concatenated with array of chars - inconsistent behavior | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1059 Summary: String literal concatenated with array of chars - inconsistent behavior Product: D Version: 1.009 Platform: PC OS/Version: Linux Status: NEW Severity: minor Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: gavrilyak@gmail.com char[] hi1 = "h" ~ "i"; //works char[] hi1 = "h" ~ ['i']; //works char[] hi2 = ['h'] ~ "i"; // semicolon expected, not '~' //found '~' instead of statement char[] hi3 = ['h'] ~ ['i'];// semicolon expected, not '~' //found '~' instead of statement All 4 case means the same and should behave the same way. -- |
March 13, 2007 [Issue 1059] String literal concatenated with array of chars - inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1059 ------- Comment #1 from gavrilyak@gmail.com 2007-03-13 16:44 ------- Update: This issue occurs only in initialization, normal assignment works. char[] hi = "h" ~ "i"; //works char[] hi1 = "h" ~ ['i']; //works char[] hi2 = ['h'] ~ "i"; // semicolon expected, not '~' //found '~' instead of statement char[] hi3 = ['h'] ~ ['i'];// semicolon expected, not '~' //found '~' instead of statement hi1 = "h" ~ ['i']; //works hi1 = ['h'] ~ "i"; //works hi1 = ['h'] ~ ['i']; //works -- |
August 23, 2008 [Issue 1059] String literal concatenated with array of chars - inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1059 matti.niemenmaa+dbugzilla@iki.fi changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |matti.niemenmaa+dbugzilla@ik | |i.fi Severity|minor |normal OS/Version|Linux |All Platform|PC |All ------- Comment #2 from matti.niemenmaa+dbugzilla@iki.fi 2008-08-23 05:29 ------- Annoying because this limits the use of array literals in templates, A doesn't compile in the following: //template A(char a, char b) { const char[] A = [a] ~ [b]; } template B(char[] a, char[] b) { const char[] B = a ~ b ; } void main() { // static assert (A!('a', 'b') == "ab"); static assert (B!("a", "b") == "ab"); static assert (['a'] ~ ['b'] == "ab"); } -- |
August 23, 2008 [Issue 1059] String literal concatenated with array of chars - inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1059 ------- Comment #3 from matti.niemenmaa+dbugzilla@iki.fi 2008-08-23 10:45 ------- The template issue can be worked around as well, replace [a,b,...] with (cast(typeof(a))[] ~ a ~ b ~ ...): template A(char a, char b) { const char[] A = cast(char[])[] ~ a ~ b; } -- |
August 23, 2008 [Issue 1059] String literal concatenated with array of chars - inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1059 ------- Comment #4 from matti.niemenmaa+dbugzilla@iki.fi 2008-08-23 11:33 ------- This one I haven't found a workaround for: template Id(char[] s) { const Id = s; } // succeed static assert (Id!("x" ~ "y") == "xy"); static assert (Id!(['x'] ~ ['y']) == "xy"); // fail static assert (Id!("x" ~ ['y']) == "xy"); static assert (Id!(['x'] ~ "y") == "xy"); The second two give errors of the form: asdf.d(7): Error: expression "x" ~ ['y'] is not a valid template value argument asdf.d(7): template instance asdf.Id!("x" ~ ['y']) error instantiating asdf.d(7): static assert ("x" ~ ['y'] == "xy") is not evaluatable at compile time -- |
June 10, 2011 [Issue 1059] String literal concatenated with array of chars - inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1059 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |FIXED --- Comment #5 from yebblies <yebblies@gmail.com> 2011-06-10 04:53:16 PDT --- These cases work in the current compilers. (dmd1.068 & dmd2.053) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation