Skip to content

Commit

Permalink
Merge pull request #5585 from 9rnsr/fix15835
Browse files Browse the repository at this point in the history
Issue 15835 - Segfault with typeid call from lazy argument
  • Loading branch information
WalterBright committed Mar 28, 2016
2 parents d2ee18c + 71294c1 commit 39d6bfa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/apply.d
Expand Up @@ -9,6 +9,7 @@
module ddmd.apply;

import ddmd.arraytypes;
import ddmd.dtemplate;
import ddmd.expression;
import ddmd.visitor;

Expand Down Expand Up @@ -73,6 +74,11 @@ public:
doCond(e.thisexp) || doCond(e.newargs) || doCond(e.arguments) || applyTo(e);
}

override void visit(TypeidExp e)
{
doCond(isExpression(e.obj)) || applyTo(e);
}

override void visit(UnaExp e)
{
doCond(e.e1) || applyTo(e);
Expand Down
1 change: 1 addition & 0 deletions src/delegatize.d
Expand Up @@ -8,6 +8,7 @@

module ddmd.delegatize;

import core.stdc.stdio;
import ddmd.apply;
import ddmd.declaration;
import ddmd.dscope;
Expand Down
21 changes: 21 additions & 0 deletions test/runnable/lazy.d
Expand Up @@ -267,6 +267,26 @@ void test9109()
foo({ return 1; }, { return 3+x; }, dg, null);
}

/*********************************************************/
// 15835

class C15835 {}

string fun15835(lazy string s)
{
return s;
}

void test15835()
{
auto c = new C15835;
auto s = typeid(c).name;
assert(fun15835(typeid(c).name) == s);

auto a = [c];
assert(fun15835(typeid(a[0]).name) == s);
}

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

int main()
Expand All @@ -283,6 +303,7 @@ int main()
test5750b();
test6682();
test9109();
test15835();

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

0 comments on commit 39d6bfa

Please sign in to comment.