Skip to content

Commit ac74653

Browse files
authored
KCL: If expressions can be used with math (#7784)
1 parent be9b71d commit ac74653

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

rust/kcl-lib/src/parsing/parser.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,7 @@ fn expr_allowed_in_pipe_expr(i: &mut TokenSlice) -> ModalResult<Expr> {
21552155

21562156
fn possible_operands(i: &mut TokenSlice) -> ModalResult<Expr> {
21572157
let mut expr = alt((
2158+
if_expr.map(Expr::IfExpression),
21582159
unary_expression.map(Box::new).map(Expr::UnaryExpression),
21592160
bool_value.map(Box::new).map(Expr::Literal),
21602161
literal.map(Expr::Literal),
@@ -4889,6 +4890,13 @@ thing(false)
48894890
crate::parsing::top_level_parse(some_program_string).unwrap();
48904891
}
48914892

4893+
#[test]
4894+
fn test_mul_if() {
4895+
let some_program_string = r#"10 * if true { 1 } else { 0}"#;
4896+
let tokens = crate::parsing::token::lex(some_program_string, ModuleId::default()).unwrap();
4897+
super::binary_expression_tokens.parse(tokens.as_slice()).unwrap();
4898+
}
4899+
48924900
#[test]
48934901
fn test_error_define_var_as_function() {
48944902
// TODO: https://github.com/KittyCAD/modeling-app/issues/784
@@ -5126,6 +5134,7 @@ sketch001 = startSketchOn(XZ) |> startProfile(at = [90.45 $struct])"#;
51265134
[52, 53],
51275135
);
51285136
}
5137+
51295138
#[test]
51305139
fn test_parse_array_random_brace() {
51315140
let some_program_string = r#"

0 commit comments

Comments
 (0)