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
3 changes: 2 additions & 1 deletion compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,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 @@ -1796,6 +1795,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
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; }