Skip to content

Commit e7f4897

Browse files
committed
wip: f me up
1 parent 5ae27cc commit e7f4897

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

fire/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ mod tests {
564564
halloween()
565565
};
566566

567-
let result = fir!(ast).interpret();
568-
assert_eq!(result, Some(Instance::from("different string")))
567+
// let result = fir!(ast).interpret();
568+
// assert_eq!(result, Some(Instance::from("different string")))
569569
}
570570

571571
#[test]

xparser/src/constructs.rs

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,18 +763,22 @@ pub fn block(input: ParseInput) -> ParseResult<ParseInput, Ast> {
763763
let input = next(input);
764764
let (input, start_loc) = position(input)?;
765765

766-
if let Ok((input, _)) = tokens::if_tok(input) {
767-
unit_if(input, start_loc.into())
766+
let (input, stmt) = if let Ok((input, _)) = tokens::if_tok(input) {
767+
unit_if(input, start_loc.into())?
768768
} else if let Ok((input, kind)) =
769769
alt((tokens::func_tok, tokens::test_tok, tokens::mock_tok))(input)
770770
{
771-
unit_func(input, kind, start_loc.into())
771+
unit_func(input, kind, start_loc.into())?
772772
} else if tokens::left_curly_bracket(input).is_ok() {
773773
// we don't update `input` here so that we can just call `block`
774-
block(input)
774+
block(input)?
775775
} else {
776-
expr_semicolon(input)
777-
}
776+
expr_semicolon(input)?
777+
};
778+
779+
let (input, _) = opt(tokens::semicolon)(input)?;
780+
781+
Ok((input, stmt))
778782
};
779783

780784
let (input, stmts) = opt(many1(stmt))(input)?;
@@ -2329,4 +2333,37 @@ mod tests {
23292333

23302334
assert!(expr(input).is_ok());
23312335
}
2336+
2337+
#[test]
2338+
fn early_return395() {
2339+
let input = span!("func halloween(b: bool) -> int { if b { return 14 }; 15 }");
2340+
2341+
assert!(expr(input).is_ok());
2342+
}
2343+
2344+
#[test]
2345+
fn inner_block_with_semi395() {
2346+
let input = span!(
2347+
"func halloween() -> int { func inner() -> int { { { { { return 14; } } } } }; 15 }"
2348+
);
2349+
2350+
assert!(expr(input).is_ok())
2351+
}
2352+
2353+
#[test]
2354+
fn inner_nested_function395() {
2355+
let input = span! {r#"
2356+
func halloween() -> string {
2357+
func inner() -> string {
2358+
{ { { {
2359+
return "boo";
2360+
} } } }
2361+
};
2362+
2363+
"different string"
2364+
}
2365+
"#};
2366+
2367+
assert!(expr(input).is_ok())
2368+
}
23322369
}

0 commit comments

Comments
 (0)