From 12ff8b04513665cca41d41ff79f7ee9dc95044db Mon Sep 17 00:00:00 2001 From: Teakowa Date: Tue, 13 Oct 2026 19:35:01 +0800 Subject: [PATCH] test(parser): cover surplus action arguments in canonical arity validation Wait(1, 2, 3, 4, 5) is already rejected with 'action \'wait\' expects 1..2 argument(s), got 5', and the CLI test covers parse/emit/convert. Add the missing library-side case so canonical validation and the CLI are pinned to the same diagnostic. Fixes #430 --- crates/workshop-rs/tests/parser.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/workshop-rs/tests/parser.rs b/crates/workshop-rs/tests/parser.rs index 1ab90c9f..61b0fe27 100644 --- a/crates/workshop-rs/tests/parser.rs +++ b/crates/workshop-rs/tests/parser.rs @@ -460,6 +460,19 @@ fn canonical_validation_enforces_declared_arity_and_enum_domain() { .contains("action 'wait' expects 1..2 argument(s), got 0") ); + // Surplus arguments past the non-variadic signature are rejected with + // the same named-arity diagnostic the CLI reports (workshop-rs#430). + let surplus = + r#"rule ("surplus") { event { Ongoing - Global; } actions { Wait(1, 2, 3, 4, 5); } }"#; + let program = internal::parse(surplus); + let error = validate::validate_canonical_ids_wir(&program, &catalog) + .expect_err("surplus signature arguments must be rejected"); + assert!( + error + .to_string() + .contains("action 'wait' expects 1..2 argument(s), got 5") + ); + // A partially supplied signature is rejected with a source-located // diagnostic, not only an empty argument list (workshop-rs#341). let partial = r#"rule ("partial") { event { Ongoing - Global; } actions { Big Message(All Players(All Teams)); } }"#;