Skip to content

Commit

Permalink
fix Issue 17612 - [REG2.063] Segmentation fault with bad object.d
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jul 6, 2017
1 parent 74a4ecc commit 9e486c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ddmd/dclass.d
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,19 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
// If no base class, and this is not an Object, use Object as base class
if (!baseClass && ident != Id.Object && !cpp)
{
if (!object)
void badObjectDotD()
{
error("missing or corrupt object.d");
fatal();
}

if (!object || object.errors)
badObjectDotD();

Type t = object.type;
t = t.semantic(loc, sc).toBasetype();
if (t.ty == Terror)
badObjectDotD();
assert(t.ty == Tclass);
TypeClass tc = cast(TypeClass)t;

Expand Down
17 changes: 17 additions & 0 deletions test/fail_compilation/fail17612.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* TEST_OUTPUT:
---
fail_compilation/fail17612.d(14): Error: undefined identifier `string`
fail_compilation/fail17612.d(17): Error: class object.TypeInfo missing or corrupt object.d
---
*/

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

module object;

class Object
{
string toString();
}

class TypeInfo {}

0 comments on commit 9e486c3

Please sign in to comment.