diff --git a/src/wasm-lib/kcl/src/executor.rs b/src/wasm-lib/kcl/src/executor.rs index 6d3e42808..0dc0aa6cd 100644 --- a/src/wasm-lib/kcl/src/executor.rs +++ b/src/wasm-lib/kcl/src/executor.rs @@ -795,7 +795,9 @@ pub async fn execute( for statement in &program.body { match statement { BodyItem::ExpressionStatement(expression_statement) => { - if let Value::CallExpression(call_expr) = &expression_statement.expression { + if let Value::PipeExpression(pipe_expr) = &expression_statement.expression { + pipe_expr.get_result(memory, &mut pipe_info, ctx).await?; + } else if let Value::CallExpression(call_expr) = &expression_statement.expression { let fn_name = call_expr.callee.name.to_string(); let mut args: Vec = Vec::new(); for arg in &call_expr.arguments { diff --git a/src/wasm-lib/tests/executor/main.rs b/src/wasm-lib/tests/executor/main.rs index 3eae98805..7177a46a7 100644 --- a/src/wasm-lib/tests/executor/main.rs +++ b/src/wasm-lib/tests/executor/main.rs @@ -518,3 +518,23 @@ show(part)"#; let result = execute_and_snapshot(code).await.unwrap(); twenty_twenty::assert_image("tests/executor/outputs/rounded_with_holes.png", &result, 0.999); } + +#[tokio::test(flavor = "multi_thread")] +async fn serial_test_top_level_expression() { + let code = r#"fn circle = (pos, radius) => { + const sg = startSketchOn('XY') + |> startProfileAt([pos[0] + radius, pos[1]], %) + |> arc({ + angle_end: 360, + angle_start: 0, + radius: radius + }, %) + |> close(%) + return sg +} + +circle([0,0], 22) |> extrude(14, %)"#; + + let result = execute_and_snapshot(code).await.unwrap(); + twenty_twenty::assert_image("tests/executor/outputs/top_level_expression.png", &result, 0.999); +} diff --git a/src/wasm-lib/tests/executor/outputs/top_level_expression.png b/src/wasm-lib/tests/executor/outputs/top_level_expression.png new file mode 100644 index 000000000..bd2eb0fd2 Binary files /dev/null and b/src/wasm-lib/tests/executor/outputs/top_level_expression.png differ