Fix #21105: Is-expressions should not generate unnecessary code for lowerings (#21106)

treat as if compiling with __traits(compiles)
This commit is contained in:
Rainer Schuetze 2025-03-29 01:36:10 +01:00 committed by GitHub
parent cfa763d301
commit 13d0a42ad5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 1 deletions

View file

@ -64,7 +64,7 @@ private extern (D) struct BitFields
bool inTemplateConstraint; /// inside template constraint
Contract contract;
bool ctfe; /// inside a ctfe-only expression
bool traitsCompiles; /// inside __traits(compile)
bool traitsCompiles; /// inside __traits(compile) or is-expression
/// ignore symbol visibility
/// https://issues.dlang.org/show_bug.cgi?id=15907
bool ignoresymbolvisibility;

View file

@ -7304,6 +7304,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
sc2.tinst = null;
sc2.minst = null;
sc2.fullinst = true;
sc2.traitsCompiles = true;
Type t = dmd.typesem.trySemantic(e.targ, e.loc, sc2);
sc2.pop();
if (!t) // errors, so condition is false