Skip to content

Commit

Permalink
fix Issue 17622 - [REG2.075.0-b1] Wrong code with appender and -inline
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored and MartinNowak committed Aug 3, 2017
1 parent 95dba7d commit c73fe97
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ddmd/e2ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -2903,7 +2903,8 @@ elem *toElem(Expression e, IRState *irs)
* and have the structliteral write into v, rather than create a temporary
* and copy the temporary into v
*/
if (ae.e1.op == TOKvar && ce.e1.op == TOKdotvar)
if (e1.Eoper == OPvar && // no closure variables https://issues.dlang.org/show_bug.cgi?id=17622
ae.e1.op == TOKvar && ce.e1.op == TOKdotvar)
{
auto dve = cast(DotVarExp)ce.e1;
auto fd = dve.var.isFuncDeclaration();
Expand Down
33 changes: 33 additions & 0 deletions test/runnable/structlit.d
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,38 @@ void test14556()
assert(sb.data[] == cast(ubyte[1])[0]);
}

/********************************************/
// https://issues.dlang.org/show_bug.cgi?id=17622

struct S17622
{
int i;

this(ubyte)
{
return;
}

void fun()
{
assert(i == 0);
}
}

S17622 make()
{
return S17622(0);
}

void test17622()
{
S17622 s = make();

auto rdg = (){ s.fun(); };

s.fun();
}

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

int main()
Expand Down Expand Up @@ -1489,6 +1521,7 @@ int main()
test11256();
test13021();
test14556();
test17622();

printf("Success\n");
return 0;
Expand Down

0 comments on commit c73fe97

Please sign in to comment.