www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15711] New: Incorrect type inferring of [char]/string when


          Issue ID: 15711
           Summary: Incorrect type inferring of [char]/string when passed
                    via recursive template, extracting it from a structure
           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:

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;

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:

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("")], [])

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