From 48db254fb06f1d7c9d6fbde9189765fd4119eb3e Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Sun, 9 Jul 2023 16:42:41 +0200 Subject: [PATCH] fix if scopes and shortened function bodies --- src/dscanner/analysis/base.d | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/dscanner/analysis/base.d b/src/dscanner/analysis/base.d index 300ce05..daa0736 100644 --- a/src/dscanner/analysis/base.d +++ b/src/dscanner/analysis/base.d @@ -525,12 +525,14 @@ public: mixin ScopedVisit!BlockStatement; mixin ScopedVisit!ForeachStatement; mixin ScopedVisit!ForStatement; - mixin ScopedVisit!IfStatement; mixin ScopedVisit!Module; mixin ScopedVisit!StructBody; mixin ScopedVisit!TemplateDeclaration; mixin ScopedVisit!WithStatement; mixin ScopedVisit!WhileStatement; + mixin ScopedVisit!DoStatement; + // mixin ScopedVisit!SpecifiedFunctionBody; // covered by BlockStatement + mixin ScopedVisit!ShortenedFunctionBody; override void visit(const SwitchStatement switchStatement) { @@ -540,6 +542,23 @@ public: switchStatement.accept(this); } + override void visit(const IfStatement ifStatement) + { + pushScopeImpl(); + if (ifStatement.condition) + ifStatement.condition.accept(this); + if (ifStatement.thenStatement) + ifStatement.thenStatement.accept(this); + popScopeImpl(); + + if (ifStatement.elseStatement) + { + pushScopeImpl(); + ifStatement.elseStatement.accept(this); + popScopeImpl(); + } + } + static foreach (T; AliasSeq!(CaseStatement, DefaultStatement, CaseRangeStatement)) override void visit(const T stmt) {