Only create scope in LetDeclaration if it is a function

This commit is contained in:
Sam Vervaeck 2023-06-12 16:50:55 +02:00
parent d81e92231f
commit 35bcf38eb3
Signed by: samvv
SSH key fingerprint: SHA256:dIg0ywU1OP+ZYifrYxy8c5esO72cIKB+4/9wkZj1VaY

View file

@ -1995,11 +1995,14 @@ namespace bolt {
Body(Body) {} Body(Body) {}
inline Scope* getScope() override { inline Scope* getScope() override {
if (isFunction()) {
if (TheScope == nullptr) { if (TheScope == nullptr) {
TheScope = new Scope(this); TheScope = new Scope(this);
} }
return TheScope; return TheScope;
} }
return Parent->getScope();
}
bool isInstance() const noexcept { bool isInstance() const noexcept {
return Parent->getKind() == NodeKind::InstanceDeclaration; return Parent->getKind() == NodeKind::InstanceDeclaration;