www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20484] New: Regression: runtime cannot handle shared(AA)

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

          Issue ID: 20484
           Summary: Regression: runtime cannot handle shared(AA)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: james.blachly gmail.com

I posted question related to the following on D.learn on 2019/11/17.
https://forum.dlang.org/thread/qqrpu5$1nft$1 digitalmars.com


Summary:
--------
We experience failures to compile codebase with shared(AA) beginning with
frontend version 2.087.

Culprit:
--------
Commit/lines
https://github.com/dlang/druntime/commit/af86e7db58f4b792e45bdc3ee43c17aadc9d54ab#diff-a68e58fcf0de5aa198fcaceafe4e8cf9L3430-R3454
seems to have introduced a regression whereby the runtime cannot handle
shared(AA). I should note that this commit ("object: Declare private struct AA
and fix aaA function signatures ") is not mentioned in the changelog which made
tracking it down much harder. 

Example:
--------
A minimal reproducible example is available here:
https://gist.github.com/jblachly/78c5762bbfea65b09e7a1417ad763019 (shorten
function on run.dlang.io is still broken) and is pasted below. You can select
"all DMD compilers" on run.dlang.io to see that this breaks at 2.087.1.


```
import std.stdio;

struct B
{
    int[int] xx;
}

struct A
{
    B b;
}

void main()
{
    shared A a;

    a.b.xx[1] = 2;
    a.b.xx[2] = 4;
    a.b.xx[4] = 8;

    foreach(int k; a.b.xx.keys)
        writeln(k);
    foreach(int v; a.b.xx.values)
        writeln(v);
}
```

Output:
```
           2.087.1: Failure with output:
-----
/path/to/dmd.linux/dmd2/linux/bin64/../../src/druntime/import/object.d(3417):
Error: cannot implicitly convert expression `aa` of type `shared(int[int])` to
`const(shared(int)[int])`
onlineapp.d(21): Error: template instance `object.keys!(shared(int[int]),
shared(int), int)` error instantiating
/path/to/dmd.linux/dmd2/linux/bin64/../../src/druntime/import/object.d(3468):
Error: cannot implicitly convert expression `aa` of type `shared(int[int])` to
`const(shared(int)[int])`
onlineapp.d(23): Error: template instance `object.values!(shared(int[int]),
shared(int), int)` error instantiating
```

Thanks all for your help

--
Jan 06