Refactor: Implement block scoping and statement separation
This commit introduces fundamental changes to Myc's language structure to enhance type safety and scoping clarity. Key changes include: - Introducing local scopes for `do` blocks. - Separating statements (`def`, `assign`) from expressions, where statements now have no return value and are only allowed within blocks. - A block now consists of multiple statements followed by a single final expression. - Stricter validation rules are enforced, such as disallowing redefinition of local symbols in the same scope while allowing shadowing of outer symbols. - Compiler errors are generated for statements used in expression contexts. The implementation involved modifications to the AST, parser, binder (scope-stack), and various compiler passes, along with VM runtime optimizations.
This commit is contained in:
+2
-1
@@ -96,7 +96,8 @@ pub enum UntypedKind {
|
||||
lambda: Box<Node<UntypedKind>>,
|
||||
},
|
||||
Block {
|
||||
exprs: Vec<Node<UntypedKind>>,
|
||||
statements: Vec<Node<UntypedKind>>,
|
||||
result: Box<Node<UntypedKind>>,
|
||||
},
|
||||
Tuple {
|
||||
elements: Vec<Node<UntypedKind>>,
|
||||
|
||||
Reference in New Issue
Block a user