Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix Issue 7152 - Can't assign null to default argument

This had not implemented as a part of issue 7019.
  • Loading branch information...
commit e418d1e1072d4bf7254e759cdc0ad975d45ceed3 1 parent 08f0048
@9rnsr 9rnsr authored
Showing with 9 additions and 3 deletions.
  1. +3 −3 src/mtype.c
  2. +6 −0 test/runnable/declaration.d
View
6 src/mtype.c
@@ -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,
View
6 test/runnable/declaration.d
@@ -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();
}
/***************************************************/
Please sign in to comment.
Something went wrong with that request. Please try again.