Fix Bugzilla 24365 - ICE when printing showCtfeContext error (#16131)

This commit is contained in:
Razvan Nitu 2024-02-02 02:06:03 +02:00 committed by GitHub
parent d318d9a534
commit c0101e095e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -1343,9 +1343,10 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
dsym._init = dsym._init.initializerSemantic(sc, dsym.type, sc.intypeof == 1 ? INITnointerpret : INITinterpret);
import dmd.semantic2 : lowerStaticAAs;
lowerStaticAAs(dsym, sc);
const init_err = dsym._init.isExpInitializer();
auto init_err = dsym._init.isExpInitializer();
if (init_err && init_err.exp.op == EXP.showCtfeContext)
{
init_err.exp = ErrorExp.get();
errorSupplemental(dsym.loc, "compile time context created here");
}
}

View file

@ -0,0 +1,20 @@
// https://issues.dlang.org/show_bug.cgi?id=243645
/*
TEST_OUTPUT:
---
fail_compilation/test24365.d(16): Error: `f` cannot be interpreted at compile time, because it has no available source code
fail_compilation/test24365.d(14): compile time context created here
fail_compilation/test24365.d(19): while evaluating: `static assert(r == 2)`
---
*/
void main()
{
enum r = () {
void f();
f();
return 2;
}();
static assert(r == 2);
}