Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions compiler/src/dmd/e2ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
11 changes: 3 additions & 8 deletions compiler/src/dmd/s2ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dmd/toir.d
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions compiler/test/fail_compilation/fail22039.d
Original file line number Diff line number Diff line change
@@ -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; }