From aa48973e235e45c085c9aa7b3859ac3a25db8774 Mon Sep 17 00:00:00 2001 From: Emmanuel Benoit Date: Wed, 11 Jan 2023 15:19:21 +0100 Subject: [PATCH] Resolver - Support and detection of the initializer scope type --- src/resolver.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/resolver.rs b/src/resolver.rs index f35830a..fa47279 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -44,8 +44,13 @@ enum SymKind { /// The type of a scope #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum ScopeType { + /// The scope is contained by the top-level scope. TopLevel, + /// The scope is contained by a function. Function, + /// The scope is contained by an instance initializer. + Initializer, + /// The scope is contained by a method. Method, } @@ -269,7 +274,11 @@ where methods.iter().try_for_each(|method| { rs.with_scope( |rs| resolve_function(rs, &method.params, &method.body), - ScopeType::Method, + if method.name.lexeme == "init" { + ScopeType::Initializer + } else { + ScopeType::Method + }, ) }) }