digitalmars.D.bugs - [Issue 15711] New: Incorrect type inferring of [char]/string when
- via Digitalmars-d-bugs (46/46) Feb 21 2016 https://issues.dlang.org/show_bug.cgi?id=15711
https://issues.dlang.org/show_bug.cgi?id=15711 Issue ID: 15711 Summary: Incorrect type inferring of [char]/string when passed via recursive template, extracting it from a structure field Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: blocker Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: iamtakingiteasy eientei.org Hello, having a snip main.d like this: --->3--- struct Quu { string val; } string[] result = foo!(0, [Quu(['z']), Quu("")]); template foo(size_t i, Quu[] data, string[] results = []) { static if (i < data.length) { enum def = data[i]; enum foo = foo!(i+1, data, results ~ def.val); } else { enum foo = results; } } --->3--- which is supposed to be a recursive template implementation, converting Quu[] to string[] by extracting Quu's member 'val' at compile-time, it fails on current dmd's HEAD of git master: eb8c2c7a48404495d3a62ee5bd58e28a654e99d5 as well as on current 2.070.0 release with the folliwng message: --->3--- main.d(9): Error: cannot implicitly convert expression ([['z'], ""]) of type const(char)[][] to string[] main.d(9): Error: template instance main.foo!(1LU, [Quu(['z']), Quu("")], [['z']]) error instantiating main.d(5): instantiated from here: foo!(0LU, [Quu(['z']), Quu("")], []) --->3--- and i wasn't able to find any cast()ing or to!()-converting workaround at this point, so this why i consider severity as 'blocker', as it prevents me from proceeding at my coding task, please correct me if i am wrongfully considered it so. --
Feb 21 2016