diff --git a/compiler/src/dmd/dsymbolsem.d b/compiler/src/dmd/dsymbolsem.d index 2e8225108b6c..dfea05ec9474 100644 --- a/compiler/src/dmd/dsymbolsem.d +++ b/compiler/src/dmd/dsymbolsem.d @@ -4014,7 +4014,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor //printf("UserAttributeDeclaration::semantic() %p\n", this); if (uad.decl && !uad._scope) uad.Dsymbol.setScope(sc); // for function local symbols - arrayExpressionSemantic(uad.atts.peekSlice(), sc, true); + Scope* sc2 = sc.startCTFE(); + arrayExpressionSemantic(uad.atts.peekSlice(), sc2, true); + sc2.endCTFE(); return attribSemantic(uad); } diff --git a/compiler/test/fail_compilation/fail20012.d b/compiler/test/fail_compilation/fail20012.d new file mode 100644 index 000000000000..f30a88c15d80 --- /dev/null +++ b/compiler/test/fail_compilation/fail20012.d @@ -0,0 +1,9 @@ +/* https://github.com/dlang/dmd/issues/20012 +TEST_OUTPUT: +--- +fail_compilation/fail20012.d(8): Error: array cast from `string` to `dstring` is not supported at compile time +fail_compilation/fail20012.d(9): Error: array cast from `string` to `dstring` is not supported at compile time +--- +*/ +enum a = cast(dstring) "what"c; +@(cast(dstring) "huh"c) int x;