Thread overview
[Issue 24735] Enum is not work within the member function in the synchronized class
August 31
https://issues.dlang.org/show_bug.cgi?id=24735

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #1 from Nick Treleaven <nick@geany.org> ---
> source\text.d(14,12): Error: direct access to shared `ENUM1` is not allowed, see `core.atomic`

With -preview=nosharedaccess.
Fixed by https://github.com/dlang/dmd/pull/16788

> source\text.d(27,5): Error: `shared` method `text.A.f` is not callable using a non-shared object

I think that's intentional.

--
August 31
https://issues.dlang.org/show_bug.cgi?id=24735

--- Comment #2 from Haruki Shigemori <rayerd.wiz@gmail.com> ---
enum
{
        ENUM1 = 1
}

enum ENUM2 = 2;

synchronized class A
{
        void f()
        {
                auto a = ENUM1; // NG, but ENUM1 is constant.
                auto b = ENUM2; // OK
        }
}

void main()
{
        auto a = new shared(A);
        a.f();
}

source\text.d(12,12): Error: direct access to shared `ENUM1` is not allowed,
see `core.atomic`

Why is ENUM1 shared and ENUM2 not shared?

--
August 31
https://issues.dlang.org/show_bug.cgi?id=24735

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Nick Treleaven <nick@geany.org> ---
Comment 2 compiles without error with -preview=nosharedaccess and dmd git master.

--
August 31
https://issues.dlang.org/show_bug.cgi?id=24735

--- Comment #4 from Haruki Shigemori <rayerd.wiz@gmail.com> ---
Sorry!
I forgot to set the -preview=all option.

--