Fix Issue 12461 - Typedef and opOpAssign

This commit is contained in:
Bernhard Seckinger 2019-12-30 13:25:00 +01:00
parent e8a4e9cb74
commit 998ac2bc36

View file

@ -6771,7 +6771,7 @@ mixin template Proxy(alias a)
auto ref opOpAssign (string op, this X, V )(auto ref V v)
{
return mixin("a " ~op~"= v");
return mixin("a = a "~op~" v");
}
auto ref opIndexOpAssign(string op, this X, V, D...)(auto ref V v, auto ref D i)
{
@ -7480,6 +7480,16 @@ struct Typedef(T, T init = T.init, string cookie=null)
static assert(!is(MoneyEuros == MoneyDollars));
}
// issue 12461
@safe unittest
{
alias Int = Typedef!int;
Int a, b;
a += b;
assert(a == 0);
}
/**
Get the underlying type which a `Typedef` wraps.
If `T` is not a `Typedef` it will alias itself to `T`.