Browse Source

fix: missing nested expression braces

github-actions
Garrit Franke 3 years ago
parent
commit
78650f7f42
  1. 1
      TODO
  2. 8
      examples/playground.sb
  3. 2
      src/generator/js.rs

1
TODO

@ -1,5 +1,4 @@
# Bugs # Bugs
- Generated nested expressions should include braces
# Cleanups # Cleanups
- Improve error reporting (See ./util/string_util::highlight_position_in_file) - Improve error reporting (See ./util/string_util::highlight_position_in_file)

8
examples/playground.sb

@ -1,9 +1,5 @@
fn main() { fn main() {
let arr = [[11, 12, 13], [21, 22, 23], [31, 32, 33]] let x = (1 + (2 * 3))
for i in arr { print(x)
for j in i {
println(j)
}
}
} }

2
src/generator/js.rs

@ -244,7 +244,7 @@ fn generate_bin_op(left: Expression, op: BinOp, right: Expression) -> String {
BinOp::Subtraction => "-", BinOp::Subtraction => "-",
}; };
format!( format!(
"{l} {op} {r}", "({l} {op} {r})",
l = generate_expression(left), l = generate_expression(left),
op = op_str, op = op_str,
r = generate_expression(right) r = generate_expression(right)

Loading…
Cancel
Save