diff --git a/crates/codegen/src/ts.rs b/crates/codegen/src/ts.rs index 8acba21..756f4dd 100644 --- a/crates/codegen/src/ts.rs +++ b/crates/codegen/src/ts.rs @@ -74,7 +74,7 @@ impl Codegen { .collect::>(). 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 }, diff --git a/example/err/do_end_scope.hz b/example/err/do_end_scope.hz new file mode 100644 index 0000000..eb68631 --- /dev/null +++ b/example/err/do_end_scope.hz @@ -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; \ No newline at end of file