Manjaro/Arch x86_64, dmd v2.100.0, ldc 1.29.0.
A struct used as a UDA fails to compile if it has an `opDispatch` which invokes writeln.
---
import std.stdio;
struct UDA
{
string _hello;
void opDispatch(string var, T)(T value)
{
writeln("opDispatch ", var);
enum realVar = '_' ~ var;
mixin(realVar) = value;
}
}
@(UDA()
.hello("hi")
)
struct Foo {}
void main() {}
---
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d(5190): Error: variable `impl` cannot be modified at compile time
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d(4130): called from here: `makeGlobal()`
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d(4235): called from here: `trustedStdout()`
onlineapp.d(9): called from here: `writeln("opDispatch ", "hello")`
onlineapp.d(16): called from here: `UDA(null).opDispatch("hi")`
Comment #1 by robert.schadek — 2024-12-13T19:23:43Z