fix Issue 23439 - [REG 2.098] Error: CTFE internal error: literal 'assert(false, "Accessed expression of type noreturn")' (#14596)

This commit is contained in:
Iain Buclaw 2022-10-27 08:01:55 +02:00 committed by GitHub
parent 020d7c216b
commit 048be13548
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View file

@ -2867,6 +2867,12 @@ public:
else else
m = v.getConstInitializer(true); m = v.getConstInitializer(true);
} }
else if (v.type.isTypeNoreturn())
{
// Noreturn field with default initializer
(*elems)[fieldsSoFar + i] = null;
continue;
}
else else
m = v.type.defaultInitLiteral(e.loc); m = v.type.defaultInitLiteral(e.loc);
if (exceptionOrCant(m)) if (exceptionOrCant(m))

View file

@ -0,0 +1,8 @@
// https://issues.dlang.org/show_bug.cgi?id=23439
// PERMUTE_ARGS: -lowmem
class C23439
{
noreturn f23439;
}
__gshared ice23439 = new C23439();

View file

@ -0,0 +1,13 @@
// https://issues.dlang.org/show_bug.cgi?id=23439
// PERMUTE_ARGS: -lowmem
/* TEST_OUTPUT:
---
fail_compilation/fail23439.d(13): Error: variable `fail23439.ice23439` is a thread-local class and cannot have a static initializer. Use `static this()` to initialize instead.
---
*/
class C23439
{
noreturn f23439;
}
static ice23439 = new C23439();