Comment #0 by n8sh.secondary — 2021-03-22T00:54:42Z
The following code compiles before v2.092 but fails to compile in v2.092 due to `@disable this(this)`. Digger identifies https://github.com/dlang/dmd/pull/10885 as the PR that broke it.
---
// Commenting out `@safe:` will make this compile with no other changes.
@safe:
struct S(bool isVeryWeird)
{
@disable this(this);
static if (isVeryWeird)
{
uint notEnum = 2;
// Changing `maybeEnum` to a non-template function will make
// this compile with no other changes.
@property uint maybeEnum()()
{
// Replacing `return notEnum` with `return 0` will make
// this compile with no other changes.
return notEnum;
}
}
else
enum uint maybeEnum = 0;
// Removing the following `static if` block will make this compile
// with no other changes.
static if (__traits(compiles, { enum e = maybeEnum; }))
{
// Empty
}
@property S spawnAnother()() const
{
S result;
return result;
}
}
void main()
{
auto a = S!false.init;
auto b = a.spawnAnother; // Succeeds.
auto c = S!true.init;
auto d = c.spawnAnother; // Compile error.
}
---
Comment #1 by robert.schadek — 2024-12-13T19:15:19Z