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:
@@ -139,6 +139,16 @@ impl RecordLayout {
|
||||
return layout.clone();
|
||||
}
|
||||
|
||||
if fields.is_empty() {
|
||||
let layout = std::sync::Arc::new(RecordLayout {
|
||||
fields: vec![],
|
||||
fmap: vec![],
|
||||
min_idx: 0,
|
||||
});
|
||||
reg.insert(fields, layout.clone());
|
||||
return layout;
|
||||
}
|
||||
|
||||
let mut min_idx = u32::MAX;
|
||||
let mut max_idx = 0;
|
||||
for (k, _) in &fields {
|
||||
|
||||
Reference in New Issue
Block a user