Skip to content

Commit

Permalink
fix Issue 7152 - Can't assign null to default argument
Browse files Browse the repository at this point in the history
This had not implemented as a part of issue 7019.
  • Loading branch information
9rnsr committed Jan 9, 2013
1 parent 08f0048 commit e418d1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -5617,9 +5617,9 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc)

if (fparam->defaultArg)
{ Expression *e = fparam->defaultArg;
e = e->inferType(fparam->type);
e = e->semantic(argsc);
e = resolveProperties(argsc, e);
Initializer *init = new ExpInitializer(e->loc, e);
init = init->semantic(argsc, fparam->type, INITnointerpret);
e = init->toExpression();
if (e->op == TOKfunction) // see Bugzilla 4820
{ FuncExp *fe = (FuncExp *)e;
// Replace function literal with a function symbol,
Expand Down
6 changes: 6 additions & 0 deletions test/runnable/declaration.d
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ void test7019()
static assert(ct_gs == S7019(2) && ct_gs.store == 16);
static assert(ct_ls == S7019(3) && ct_ls.store == 24);
static assert(C.ct_fs == S7019(4) && C.ct_fs.store == 32);

void foo(S7019 s = 5) // fixing bug 7152
{
assert(s.store == 5 << 3);
}
foo();
}

/***************************************************/
Expand Down

0 comments on commit e418d1e

Please sign in to comment.