February 15, 2023
https://issues.dlang.org/show_bug.cgi?id=23708

          Issue ID: 23708
           Summary: Cannot return shared class with
                    -preview=nosharedaccess
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: atila.neves@gmail.com

class Class {}
shared(Class) fun() {
    static shared Class ret;
    return ret;
}

% clear && dmd -g -debug -preview=nosharedaccess d.d && ./d
% d.d(4): Error: direct access to shared `ret` is not allowed, see
`core.atomic`

--