Comment #0 by pro.mathias.lang — 2020-01-15T08:26:31Z
For me this is similar to 17764, but the test case is much more simple.
```
import std.stdio;
void main () @safe
{
auto x = bar();
writeln(x);
}
char[] bar() @safe @nogc
{
char[128] a;
char[][2] arr = [a, a];
return foo(arr);
}
char[] foo(scope char[][] arr) @safe @nogc
{
return arr[0];
}
```
Compiled with:
path/to/dmd -preview=dip1000 -run foo.d
Will print garbage. Tested with v2.090.0 and HEAD (v2.090.0-beta.1-51-g49dfbe54f, commit of 2020-01-08).
Comment #1 by bugzilla — 2020-03-21T07:02:09Z
The problem is the line `foo(arr)` where `scope char[][2] arr` is converted to `scope char[][]`. This conversion should not be allowed, as it loses the scope-ness of the second level of indirection.
Comment #2 by bugzilla — 2020-03-21T07:05:35Z
This is illustrated by the following code:
@safe void bar() {
char[128] a;
char[][2] arr = [a, a];
char[][] a2 = arr; // should be error
return a2[0]; // oops
}
Comment #3 by pro.mathias.lang — 2020-03-21T08:57:57Z
*** Issue 20691 has been marked as a duplicate of this issue. ***