diff --git a/compiler/src/dmd/e2ir.d b/compiler/src/dmd/e2ir.d index 0daab9d3745a..9966e76548ce 100644 --- a/compiler/src/dmd/e2ir.d +++ b/compiler/src/dmd/e2ir.d @@ -6109,13 +6109,6 @@ elem *sarray_toDarray(const ref Loc loc, Type tfrom, Type tto, elem *e) private elem *getTypeInfo(Expression e, Type t, IRState* irs) { - if (irs.falseBlock) - { - /* Return null so we do not trigger the error - * about no TypeInfo - */ - return el_long(TYnptr, 0); - } assert(t.ty != Terror); genTypeInfo(e, e.loc, t, null); elem* result = el_ptr(toSymbol(t.vtinfo)); diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index 9b9fbb8ad776..d186abc05524 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -1728,7 +1728,6 @@ private bool functionParameters(const ref Loc loc, Scope* sc, const size_t nparams = tf.parameterList.length; const olderrors = global.errors; bool err = false; - *prettype = Type.terror; Expression eprefix = null; *peprefix = null; @@ -1817,6 +1816,8 @@ private bool functionParameters(const ref Loc loc, Scope* sc, return errorArgs(); } arg = p.defaultArg; + if (!arg.type) + arg = arg.expressionSemantic(sc); arg = inlineCopy(arg, sc); // __FILE__, __LINE__, __MODULE__, __FUNCTION__, and __PRETTY_FUNCTION__ arg = arg.resolveLoc(loc, sc); diff --git a/compiler/src/dmd/s2ir.d b/compiler/src/dmd/s2ir.d index f98021bffe08..2f2031648dd6 100644 --- a/compiler/src/dmd/s2ir.d +++ b/compiler/src/dmd/s2ir.d @@ -152,13 +152,8 @@ private extern (C++) class S2irVisitor : Visitor bcond.appendSucc(blx.curblock); if (s.ifbody) { - bool ctfe = s.isIfCtfeBlock(); // __ctfe is always false at runtime - const isFalse = ctfe; - - irs.falseBlock += isFalse; - Statement_toIR(s.ifbody, irs, &mystate); - if (isFalse && irs.falseBlock) - --irs.falseBlock; + if (!s.isIfCtfeBlock()) // __ctfe is always false at runtime + Statement_toIR(s.ifbody, irs, &mystate); } blx.curblock.appendSucc(bexit); @@ -726,7 +721,7 @@ private extern (C++) class S2irVisitor : Visitor Blockx *blx = irs.blx; //printf("ExpStatement.toIR(), exp: %p %s\n", s.exp, s.exp ? s.exp.toChars() : ""); - if (s.exp && !irs.falseBlock) + if (s.exp) { if (s.exp.hasCode && !(isAssertFalse(s.exp))) // `assert(0)` not meant to be covered diff --git a/compiler/src/dmd/toir.d b/compiler/src/dmd/toir.d index e5a27c62d70d..bf8d4872d207 100644 --- a/compiler/src/dmd/toir.d +++ b/compiler/src/dmd/toir.d @@ -86,7 +86,6 @@ struct IRState Label*[void*]* labels; // table of labels used/declared in function const Param* params; // command line parameters const Target* target; // target - int falseBlock; // !=0 means do not generate code bool mayThrow; // the expression being evaluated may throw bool Cfile; // use C semantics diff --git a/compiler/test/fail_compilation/fail22039.d b/compiler/test/fail_compilation/fail22039.d new file mode 100644 index 000000000000..3df834f7ad0d --- /dev/null +++ b/compiler/test/fail_compilation/fail22039.d @@ -0,0 +1,14 @@ +// https://issues.dlang.org/show_bug.cgi?id=22039 + +/* +TEST_OUTPUT: +--- +fail_compilation/fail22039.d(11): Error: recursive evaluation of `func()` +fail_compilation/fail22039.d(14): Error: recursive evaluation of `gun(func2())` +--- +*/ + +int func(int x = func()) { return x; } + +int gun() { return 2; } +int func2(int x = gun(func2())) { return x; }