Thread overview
[Issue 23964] [REG2.102] inccorect error opAssign cannot be used ... @disable
Jun 19, 2023
RazvanN
Jun 20, 2023
Dlang Bot
June 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23964

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry, rejects-valid

--
June 19, 2023
https://issues.dlang.org/show_bug.cgi?id=23964

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
The problem stems from the fact that `asdasdasd` is a system variable because it calls `foo` which is system. When the compiler tries to generate opAssign for ClusterInfoJohan it looks at the attributes of the potential opAssign/postblits/destructors it might call to deduce the attributes of the generated opAssign. Since UUID.opAssign is nogc and safe and the rest of the assignments (for oiuoi and asdasdasd) do not call any other user defined operators, the compiler wrongfully thinks that the generated opAssign should be nogc and safe. However, since we are accessing a system variable, it will issue a deprecation (which is silent normally, because errors are gagged when analyzing generated functions) which is catched when compiled with -de.

A workaround is to make `foo` @safe. That will make the code to compile.

Patch incoming.

--
June 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23964

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #15332 "Fix Issue 23964 - [REG2.102] inccorect error opAssign cannot be used …" fixing this issue:

- Fix Issue 23964 - [REG2.102] inccorect error opAssign cannot be used ... @disable

https://github.com/dlang/dmd/pull/15332

--
April 29
https://issues.dlang.org/show_bug.cgi?id=23964

--- Comment #3 from johanengelen@weka.io ---
> A workaround is to make `foo` @safe. That will make the code to compile.

Thanks, this indeed works and helps me out again now. A big problem with this bug is that it is _very_ hard to find the reason for the @disabling of opAssign in a normal codebase. So it is highly non-trivial to find out that setting @safe on a function somewhere is going to fix the compile error...

--