Anyone familiar with the implementation of `synchronized` in the compiler?

Atila Neves atila.neves at gmail.com
Mon Mar 7 17:47:31 UTC 2022


I took a cursory look at 
https://issues.dlang.org/show_bug.cgi?id=22626:

-----
     class Oops {
         synchronized void oops() {}
     }
-----
% dmd -o- -preview=nosharedaccess d.d
d.d(2): Error: direct access to shared `this` is not allowed, see 
`core.atomic`

But I soon got lost in the codebase. The issue is 
SharedCheckVisitor in expressionsem.d is checking `this`, which 
is shared, and thinks that access to it is disallowed since it 
has no idea that the member function is `synchronized`.

This is stopping me from transitioning nosharedaccess to be on by 
default.


More information about the Digitalmars-d mailing list