diff --git a/src/wasm-lib/kcl/src/std/sketch.rs b/src/wasm-lib/kcl/src/std/sketch.rs index 6d81e52ad..c22c172a8 100644 --- a/src/wasm-lib/kcl/src/std/sketch.rs +++ b/src/wasm-lib/kcl/src/std/sketch.rs @@ -1478,6 +1478,13 @@ pub(crate) async fn inner_arc( } }; + if angle_start == angle_end { + return Err(KclError::Type(KclErrorDetails { + message: "Arc start and end angles must be different".to_string(), + source_ranges: vec![args.source_range], + })); + } + let id = uuid::Uuid::new_v4(); args.batch_modeling_cmd( diff --git a/src/wasm-lib/tests/executor/main.rs b/src/wasm-lib/tests/executor/main.rs index 69dc12762..2dd1bdf5c 100644 --- a/src/wasm-lib/tests/executor/main.rs +++ b/src/wasm-lib/tests/executor/main.rs @@ -2601,3 +2601,29 @@ async fn serial_test_extrude_custom_plane() { let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap(); twenty_twenty::assert_image("tests/executor/outputs/extrude-custom-plane.png", &result, MIN_DIFF); } + +#[tokio::test(flavor = "multi_thread")] +async fn serial_test_arc_error_same_start_end() { + let code = r#"startSketchOn('XY') + |> startProfileAt([10, 0], %) + |> arc({ + angle_start: 180, + angle_end: 180, + radius: 1.5 + }, %) + |> close(%) + |> patternCircular2d({ + arcDegrees: 360, + center: [0, 0], + repetitions: 5, + rotateDuplicates: true + }, %) +"#; + + let result = execute_and_snapshot(code, UnitLength::Mm).await; + assert!(result.is_err()); + assert_eq!( + result.err().unwrap().to_string(), + r#"type: KclErrorDetails { source_ranges: [SourceRange([57, 140])], message: "Arc start and end angles must be different" }"# + ); +}