Skip to content

Commit

Permalink
Merge pull request #4705 from 9rnsr/fix14351
Browse files Browse the repository at this point in the history
[REG2.063] Issue 14351 - `inout` base class constructor can't be called
  • Loading branch information
WalterBright committed Jun 1, 2015
2 parents 8518309 + e4fd828 commit e801243
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -1932,14 +1932,17 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
//printf("[%s] fd = %s %s, %d %d %d\n", loc.toChars(), fd->toChars(), fd->type->toChars(),
// wildmatch, tf->isWild(), fd->isolateReturn());
if (!tthis)
{ assert(sc->intypeof || global.errors);
{
assert(sc->intypeof || global.errors);
tthis = fd->isThis()->type->addMod(fd->type->mod);
}
if (tf->isWild() && !fd->isolateReturn())
{
if (wildmatch)
tret = tret->substWildTo(wildmatch);
if (!tret->implicitConvTo(tthis))
int offset;
if (!tret->implicitConvTo(tthis) &&
!(MODimplicitConv(tret->mod, tthis->mod) && tret->isBaseOf(tthis, &offset) && offset == 0))
{
const char* s1 = tret ->isNaked() ? " mutable" : tret ->modToChars();
const char* s2 = tthis->isNaked() ? " mutable" : tthis->modToChars();
Expand All @@ -1951,7 +1954,8 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
tret = tthis;
}
else if (wildmatch)
{ /* Adjust function return type based on wildmatch
{
/* Adjust function return type based on wildmatch
*/
//printf("wildmatch = x%x, tret = %s\n", wildmatch, tret->toChars());
tret = tret->substWildTo(wildmatch);
Expand Down
23 changes: 23 additions & 0 deletions test/runnable/sctor.d
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,29 @@ struct S14376
}
}

/***************************************************/
// 14351

class B14351
{
this(inout int[]) inout { }
}

class D14351a : B14351
{
this(int[] arr) { super(arr); }
}

class D14351b : B14351
{
this(const int[] arr) const { super(arr); }
}

class D14351c : B14351
{
this(inout int[] arr) inout { super(arr); }
}

/***************************************************/

int main()
Expand Down

0 comments on commit e801243

Please sign in to comment.