Skip to content

Commit

Permalink
fix Issue 17451 - ICE in ddmd/declaration.d(2179)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed May 30, 2017
1 parent a6289e8 commit a98029d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ddmd/declaration.d
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ extern (C++) class VarDeclaration : Declaration
if (tv.ty == Tstruct)
{
StructDeclaration sd = (cast(TypeStruct)tv).sym;
if (!sd.dtor)
if (!sd.dtor || sd.errors)
return null;

const sz = type.size();
Expand Down
45 changes: 45 additions & 0 deletions test/fail_compilation/test17451.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* TEST_OUTPUT:
---
fail_compilation/test17451.d(22): Error: undefined identifier `allocator`
fail_compilation/test17451.d(23): Error: `long` has no effect in expression `false`
fail_compilation/test17451.d(30): Error: variable test17451.HashMap!(ThreadSlot).HashMap.__lambda2.v size of type ThreadSlot is invalid
fail_compilation/test17451.d(44): Error: template instance test17451.HashMap!(ThreadSlot) error instantiating
---
*/

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

interface ManualEvent {}

interface EventDriver {
ManualEvent createManualEvent() ;
}

struct ArraySet(Key)
{
~this()
{
try allocator;
catch false; // should never happen
}
}

struct HashMap(TValue)
{
alias Value = TValue;
static if ({ Value v; }) {}
}

struct Task {}

class Libevent2Driver : EventDriver {
Libevent2ManualEvent createManualEvent() {}
}

struct ThreadSlot {
ArraySet!Task tasks;
}

class Libevent2ManualEvent {
HashMap!ThreadSlot m_waiters;
}

0 comments on commit a98029d

Please sign in to comment.