Showing with 41 additions and 12 deletions.
  1. +5 −12 src/expression.d
  2. +36 −0 test/runnable/testrightthis.d
17 changes: 5 additions & 12 deletions src/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -3556,19 +3556,12 @@ public:
}
}
s = s.toAlias();

// Same as wthis.ident
if (s.needThis() || s.isTemplateDeclaration())
{
e = new VarExp(loc, withsym.withstate.wthis);
e = new DotIdExp(loc, e, ident);
}
else
{
Type t = withsym.withstate.wthis.type;
if (t.ty == Tpointer)
t = (cast(TypePointer)t).next;
e = typeDotIdExp(loc, t, ident);
}
// TODO: DotIdExp.semantic will find 'ident' from 'wthis' again.
// The redudancy should be removed.
e = new VarExp(loc, withsym.withstate.wthis);
e = new DotIdExp(loc, e, ident);
e = e.semantic(sc);
}
else
Expand Down
36 changes: 36 additions & 0 deletions test/runnable/testrightthis.d
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,41 @@ void test7()
static assert(!__traits(compiles, S7.bar(1)));
}

/********************************************************/
// 4350

template Mix4350() { int b; }

struct S4350
{
int a;

mixin Mix4350 mix;

int c;
template Func() { void call(int n) { c = n; } }
alias func = Func!();
}

void test4350()
{
S4350 s;

s.a = 1;
s.mix.b = 2;
s.func.call(3);
assert(s.a == 1);
assert(s.b == 2);
assert(s.c == 3);

with (s) { a = 2; }
with (s) { mix.b = 3; }
with (s) { func.call(4); }
assert(s.a == 2);
assert(s.b == 3);
assert(s.c == 4);
}

/********************************************************/
// 6430

Expand Down Expand Up @@ -604,6 +639,7 @@ int main()
test5();
test6();
test7();
test4350();
test9619();
test9633();

Expand Down