Add if-then-else statement support#213
Add if-then-else statement support#213stringhandler wants to merge 1 commit intoBlockstreamResearch:masterfrom
if-then-else statement support#213Conversation
|
Could we make the |
|
#185 is merged, so you can rebase |
4ec7a0b to
bb01ade
Compare
6855146 to
ddf467b
Compare
|
This is an if-then-else expression, by the way. |
if statement supportif-then-else statement support
|
Sorry for the long delay on this. I thought it would be much harder to review than it was, and I had a big pile of notifications to climb out from under. I should be available closer to real-time from here on out. In ddf467b: Are we intentionally allowing expressions that are not blocks? For example tests still pass with this diff: diff --git a/src/ast.rs b/src/ast.rs
index 3c32866..0ca53ba 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -1733,7 +1733,7 @@ mod test {
#[test]
fn test_if_expression_with_complex_arms() {
- let input = "if false { let x: u8 = 5; x } else { 10 }";
+ let input = "if false { let x: u8 = 5; x } else 10";
let parsed_expr = parse::Expression::parse_from_str(input).expect("Failed to parse");This seems okay to me, but it does differ from Rust and if it's intentional we should call it out. |
|
Oh interesting. I thought that was valid in Rust, but it explicitly requires blocks to avoid mistakes. I think it's worth sticking with Rust's rule of requiring brackets. I'll update it |
94c0bd8 to
f0e31f7
Compare
|
rebased with brace validation |
Built on #185, so that would need to be merged first.
Addresses #181