1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00

do blocks generate scope

This commit is contained in:
Natapat Samutpong 2022-03-20 05:53:43 +07:00
parent e40fd15928
commit cf3dccca2c
2 changed files with 10 additions and 2 deletions

View file

@ -74,7 +74,7 @@ impl Codegen {
.collect::<Vec<_>>().
join(", ");
format!(
"const f_{} = ({}): {} => {{\n{}\n}};\n",
"const f_{} = ({}): {} => {};\n",
name,
args,
return_type_hint,
@ -90,10 +90,11 @@ impl Codegen {
},
IRKind::Do { body } => {
let mut out = String::new();
let mut out = "{\n".to_string();
for expr in body {
out.push_str(&self.gen_ir(&expr, true));
}
out.push_str("}\n");
out
},

View file

@ -0,0 +1,7 @@
fun main: void = do
do
let foo: string = "Hello";
@write(foo);
end;
@write(foo); -- TODO: This is a runtime error
end;