diff --git a/include/bolt/CST.hpp b/include/bolt/CST.hpp index 3d890ddc1..4a766457d 100644 --- a/include/bolt/CST.hpp +++ b/include/bolt/CST.hpp @@ -1995,10 +1995,13 @@ namespace bolt { Body(Body) {} inline Scope* getScope() override { - if (TheScope == nullptr) { - TheScope = new Scope(this); + if (isFunction()) { + if (TheScope == nullptr) { + TheScope = new Scope(this); + } + return TheScope; } - return TheScope; + return Parent->getScope(); } bool isInstance() const noexcept {