Applying a UDA to a File-type variable makes DMD crash
Marcos Cruz
d-forum at programandala.net
Sun Dec 21 10:11:46 UTC 2025
H. S. Teoh via Digitalmars-d escribió/skribis/wrote/scrit (2025-12-20T16:38:29-0800):
> Anything that causes the compiler to crash is a compiler bug. Please
> report a bug:
Done:
https://github.com/dlang/dmd/issues/22282
> > ```D
> > enum var;
> > import std.stdio : File;
> > @var File file = File("tmp", "w");
> > ```
> It's probably a bad idea to do this in module global scope, because
> std.stdio.File is referenced counted with a dtor that closes the file
> upon exiting the scope.
Those three lines were copied from an actual program, where the variable
declaration is inside a function. For clarity I should have wrapped them
in a `main` function in my message, as I have done in the GitHub issue.
--
Marcos Cruz
More information about the Digitalmars-d
mailing list