mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 21:51:03 +03:00
treat as if compiling with __traits(compiles)
This commit is contained in:
parent
cfa763d301
commit
13d0a42ad5
4 changed files with 15 additions and 1 deletions
|
@ -64,7 +64,7 @@ private extern (D) struct BitFields
|
||||||
bool inTemplateConstraint; /// inside template constraint
|
bool inTemplateConstraint; /// inside template constraint
|
||||||
Contract contract;
|
Contract contract;
|
||||||
bool ctfe; /// inside a ctfe-only expression
|
bool ctfe; /// inside a ctfe-only expression
|
||||||
bool traitsCompiles; /// inside __traits(compile)
|
bool traitsCompiles; /// inside __traits(compile) or is-expression
|
||||||
/// ignore symbol visibility
|
/// ignore symbol visibility
|
||||||
/// https://issues.dlang.org/show_bug.cgi?id=15907
|
/// https://issues.dlang.org/show_bug.cgi?id=15907
|
||||||
bool ignoresymbolvisibility;
|
bool ignoresymbolvisibility;
|
||||||
|
|
|
@ -7304,6 +7304,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
||||||
sc2.tinst = null;
|
sc2.tinst = null;
|
||||||
sc2.minst = null;
|
sc2.minst = null;
|
||||||
sc2.fullinst = true;
|
sc2.fullinst = true;
|
||||||
|
sc2.traitsCompiles = true;
|
||||||
Type t = dmd.typesem.trySemantic(e.targ, e.loc, sc2);
|
Type t = dmd.typesem.trySemantic(e.targ, e.loc, sc2);
|
||||||
sc2.pop();
|
sc2.pop();
|
||||||
if (!t) // errors, so condition is false
|
if (!t) // errors, so condition is false
|
||||||
|
|
|
@ -106,6 +106,8 @@ template imported()
|
||||||
import imported = imports.vcg_ast_import;
|
import imported = imports.vcg_ast_import;
|
||||||
}
|
}
|
||||||
alias myImport = vcg_ast_import;
|
alias myImport = vcg_ast_import;
|
||||||
|
enum bool compiles = true;
|
||||||
|
enum bool isexp = true;
|
||||||
R!int
|
R!int
|
||||||
{
|
{
|
||||||
struct _R
|
struct _R
|
||||||
|
|
|
@ -75,3 +75,14 @@ template imported()
|
||||||
}
|
}
|
||||||
|
|
||||||
alias myImport = imported!();
|
alias myImport = imported!();
|
||||||
|
|
||||||
|
// https://github.com/dlang/dmd/issues/21105
|
||||||
|
|
||||||
|
enum compiles = __traits(compiles,{
|
||||||
|
int[] arr;
|
||||||
|
arr ~= 1;
|
||||||
|
});
|
||||||
|
enum isexp = is(typeof({
|
||||||
|
int[] arr;
|
||||||
|
arr ~= 1;
|
||||||
|
}));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue