Repository: casey/just (rust)

Issue:
bug: default and variadic parameter ordering
```
❯ just deploy 
error: Parameter `nonce` follows variadic parameter
  ——▶ Justfile:24:15
   │
24 │ deploy  *ARGS nonce="1":
   │               ^^^^^
(py313) 
lottery.multiversex on  main [!?] is 📦 v0.0.1 via 🐍 v3.13.1 via 🦀 v1.85.0 via 🅒 py313 on ☁️  (us-east-1) 
❯ just deploy 
error: Non-default parameter `ARGS` follows default parameter
  ——▶ Justfile:24:19
   │
24 │ deploy nonce="1" *ARGS:
   │                   ^^^^
(py313) 
```

The 2nd option is the way to go..

Pull request description:
Variadic star parameters may follow default parameters
Fixes #2655.

Patch:
diff --git a/src/analyzer.rs b/src/analyzer.rs
index c2c3da67..e4985072 100644
--- a/src/analyzer.rs
+++ b/src/analyzer.rs
@@ -234,11 +234,12 @@ impl<'run, 'src> Analyzer<'run, 'src> {
           parameter: parameter.name.lexeme(),
         }));
       }
+
       parameters.insert(parameter.name.lexeme());
 
       if parameter.default.is_some() {
         passed_default = true;
-      } else if passed_default {
+      } else if passed_default && parameter.is_required() {
         return Err(
           parameter
             .name
diff --git a/src/parameter.rs b/src/parameter.rs
index f5e247cb..df4375cc 100644
--- a/src/parameter.rs
+++ b/src/parameter.rs
@@ -13,6 +13,12 @@ pub(crate) struct Parameter<'src> {
   pub(crate) name: Name<'src>,
 }
 
+impl Parameter<'_> {
+  pub(crate) fn is_required(&self) -> bool {
+    self.default.is_none() && self.kind != ParameterKind::Star
+  }
+}
+
 impl ColorDisplay for Parameter<'_> {
   fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result {
     if let Some(prefix) = self.kind.prefix() {


Test patch:
diff --git a/tests/parameters.rs b/tests/parameters.rs
index 8cf93ba1..b80097db 100644
--- a/tests/parameters.rs
+++ b/tests/parameters.rs
@@ -36,3 +36,17 @@ fn parameter_default_values_may_not_use_later_parameters() {
     .status(EXIT_FAILURE)
     .run();
 }
+
+#[test]
+fn star_may_follow_default() {
+  Test::new()
+    .justfile(
+      "
+        foo bar='baz' *bob:
+          @echo {{bar}} {{bob}}
+      ",
+    )
+    .args(["foo", "hello", "goodbye"])
+    .stdout("hello goodbye\n")
+    .run();
+}