www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21572] New: Implicit conversion from `immutable(T)[][]` to

https://issues.dlang.org/show_bug.cgi?id=21572

          Issue ID: 21572
           Summary: Implicit conversion from `immutable(T)[][]` to `scope
                    const(T)[][]` is missing
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: per.nordlow gmail.com

In

 safe:
void f(scope const(char)[]) {}
void g(scope const(char)[][]) {}
unittest
{
    string x;
    f(x);
    string[] y;
    g(y);
}

g() should be allowed. Instead it currently fails

function `foo.g(scope const(char)[][] _param_0)` is not callable using argument
types `(string[])` (d-dmd)
cannot pass argument `y` of type `string[]` to parameter `scope const(char)[][]
_param_0` (d-dmd)

Perhaps conversion should be allowed in `g()` without `scope` qualifier as long
as `f()` allows it.

--
Jan 22 2021