@@ -316,6 +316,8 @@ final class DefinitionFinder : ASTVisitor
316316{
317317 override void visit (const ClassDeclaration dec)
318318 {
319+ if (! dec.structBody)
320+ return ;
319321 definitions ~= makeDefinition(dec.name.text, dec.name.line, " c" , context,
320322 [cast (int ) dec.structBody.startLocation, cast (int ) dec.structBody.endLocation]);
321323 auto c = context;
@@ -326,6 +328,8 @@ final class DefinitionFinder : ASTVisitor
326328
327329 override void visit (const StructDeclaration dec)
328330 {
331+ if (! dec.structBody)
332+ return ;
329333 if (dec.name == tok! " " )
330334 {
331335 dec.accept(this );
@@ -341,6 +345,8 @@ final class DefinitionFinder : ASTVisitor
341345
342346 override void visit (const InterfaceDeclaration dec)
343347 {
348+ if (! dec.structBody)
349+ return ;
344350 definitions ~= makeDefinition(dec.name.text, dec.name.line, " i" , context,
345351 [cast (int ) dec.structBody.startLocation, cast (int ) dec.structBody.endLocation]);
346352 auto c = context;
@@ -363,6 +369,8 @@ final class DefinitionFinder : ASTVisitor
363369
364370 override void visit (const FunctionDeclaration dec)
365371 {
372+ if (! dec.functionBody || ! dec.functionBody.blockStatement)
373+ return ;
366374 auto def = makeDefinition(dec.name.text, dec.name.line, " f" , context,
367375 [cast (int ) dec.functionBody.blockStatement.startLocation,
368376 cast (int ) dec.functionBody.blockStatement.endLocation]);
@@ -374,6 +382,8 @@ final class DefinitionFinder : ASTVisitor
374382
375383 override void visit (const Constructor dec)
376384 {
385+ if (! dec.functionBody || ! dec.functionBody.blockStatement)
386+ return ;
377387 auto def = makeDefinition(" this" , dec.line, " f" , context,
378388 [cast (int ) dec.functionBody.blockStatement.startLocation,
379389 cast (int ) dec.functionBody.blockStatement.endLocation]);
@@ -383,13 +393,17 @@ final class DefinitionFinder : ASTVisitor
383393
384394 override void visit (const Destructor dec)
385395 {
396+ if (! dec.functionBody || ! dec.functionBody.blockStatement)
397+ return ;
386398 definitions ~= makeDefinition(" ~this" , dec.line, " f" , context,
387399 [cast (int ) dec.functionBody.blockStatement.startLocation,
388400 cast (int ) dec.functionBody.blockStatement.endLocation]);
389401 }
390402
391403 override void visit (const EnumDeclaration dec)
392404 {
405+ if (! dec.enumBody)
406+ return ;
393407 definitions ~= makeDefinition(dec.name.text, dec.name.line, " g" , context,
394408 [cast (int ) dec.enumBody.startLocation, cast (int ) dec.enumBody.endLocation]);
395409 auto c = context;
@@ -400,6 +414,8 @@ final class DefinitionFinder : ASTVisitor
400414
401415 override void visit (const UnionDeclaration dec)
402416 {
417+ if (! dec.structBody)
418+ return ;
403419 if (dec.name == tok! " " )
404420 {
405421 dec.accept(this );
@@ -443,6 +459,8 @@ final class DefinitionFinder : ASTVisitor
443459
444460 override void visit (const Invariant dec)
445461 {
462+ if (! dec.blockStatement)
463+ return ;
446464 definitions ~= makeDefinition(" invariant" , dec.line, " v" , context,
447465 [cast (int ) dec.index, cast (int ) dec.blockStatement.endLocation]);
448466 }
0 commit comments