A lazy string crashes the compiler
An example from the Readme, reduced:
import argparse;
struct T {
@(PositionalArgument(0).Description(() => "Argument description"))
string param0;
}
void main() {
CLI!T.parseArgs!((T t) { })(["-h"]); // SIGILL
}
DMD 2.105.3.
I reproduced this issue. Will run dustmite to minimize test case.
Reduced test case:
void main() {
CLI; // SIGILL
}
template CLI()
{
static parseKnownArgs()
{
callParser!(Config.init)();
}
}
struct Config
{
enum StylingMode { autodetect}
StylingMode stylingMode ;
}
auto enableStyling(Config config)(bool enable)
{
Config c ;
c.stylingMode = enable ? Config.StylingMode: Config.StylingMode;
return c;
}
bool callParser(Config config)()
{
callParser!(enableStyling!(Config.init)(false));
}
Crashes with:
$ /usr/bin/dmd source.reduced/app.d
source.reduced/app.d(22): Error: CTFE internal error: literal `StylingMode`
Illegal instruction
I'll try to split callParser functions into two.
c.stylingMode = enable ? Config.StylingMode: Config.StylingMode;
But Config.StylingMode is a type, not a value. Dustmite made a mistake in the process and reduced to it, not the actual bug we’re hunting.
c.stylingMode = enable ? Config.StylingMode: Config.StylingMode;But
Config.StylingModeis a type, not a value. Dustmite made a mistake in the process and reduced to it, not the actual bug we’re hunting.
This looks similar to https://issues.dlang.org/show_bug.cgi?id=24246
Any idea how to proceed with this issue while ICE is not fixed?