dmd
dmd copied to clipboard
Incorrect function contract syntax segfaults the compiler.
Mistakingly I wrote out(expr) instead of out(; expr) on a ctor.
In this specific case it segfaults the compiler:
abstract class C1 {}
class C2 : C1
{
bool member;
this()
out (member)
{
}
}
Seems to happen at src/dmd/dsymbolsem.d+2425.
Without inheriting from C1, dmd gives:
outid.d(7): Error: constructor `outid.C2.this` `in` and `out` contracts can only appear without a body when they are virtual interface functions or abstract
The problem seems to be that fbody is null after parsing, but it gets generated, so the above error is not triggered:
if (!funcdecl.fbody && !funcdecl.allowsContractWithoutBody())
.error(funcdecl.loc, "%s `%s` `in` and `out` contracts can only appear without a body when they are virtual interface functions or abstract", funcdecl.kind, funcdecl.toPrettyChars);