From af7246e7b80762fd800478b7cdac1af5cf5ed067 Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Sun, 14 Jun 2026 13:47:48 +0900 Subject: [PATCH 1/4] add AsteriskInRange error --- crates/jlabel-question/src/parse_position.rs | 11 +++++++++++ crates/jlabel-question/src/tests.rs | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/crates/jlabel-question/src/parse_position.rs b/crates/jlabel-question/src/parse_position.rs index cd4f5fc..e08f5cd 100644 --- a/crates/jlabel-question/src/parse_position.rs +++ b/crates/jlabel-question/src/parse_position.rs @@ -27,6 +27,9 @@ pub enum PositionError { /// The suffix (string after the range section) conflicts with the estimated position. #[error("Suffix has unknown sequence")] SuffixVerifyError, + /// The range section contains an asterisk, which is not allowed. + #[error("Asterisk is not allowed in range section")] + AsteriskInRange, /// Range section is empty. This pattern does not match any label. #[error("Range is empty")] EmptyRange, @@ -153,6 +156,9 @@ impl<'a> PositionSplit<'a> { if self.range.is_empty() { return Err(PositionError::EmptyRange); } + if self.range.contains('*') { + return Err(PositionError::AsteriskInRange); + } Ok(self.range) } } @@ -352,6 +358,11 @@ mod tests { Err(PositionError::SuffixVerifyError) ); + assert_eq!( + estimate_position("*/A:0+*/B:+*"), + Err(PositionError::AsteriskInRange) + ); + assert_eq!( estimate_position("*/B :0+*"), Err(PositionError::NoMatchingPosition) diff --git a/crates/jlabel-question/src/tests.rs b/crates/jlabel-question/src/tests.rs index 984d377..f742ffa 100644 --- a/crates/jlabel-question/src/tests.rs +++ b/crates/jlabel-question/src/tests.rs @@ -86,6 +86,14 @@ fn parse_question_err() { AllQuestion::parse(&["*/A:0/B:*"]), Err(InvalidPosition(SuffixVerifyError)) ); + assert_eq!( + AllQuestion::parse(&["*^k-o+*"]), + Err(InvalidPosition(SuffixVerifyError)) + ); + assert_eq!( + AllQuestion::parse(&["*-N+*+1+*"]), + Err(InvalidPosition(AsteriskInRange)) + ); } #[test] From 23b77b8ec38884fdbfe8b64f24015e1c41dcbeb9 Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Sun, 14 Jun 2026 18:54:00 +0900 Subject: [PATCH 2/4] better comment --- crates/jlabel-question/src/parse_position.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/jlabel-question/src/parse_position.rs b/crates/jlabel-question/src/parse_position.rs index e08f5cd..879fdf6 100644 --- a/crates/jlabel-question/src/parse_position.rs +++ b/crates/jlabel-question/src/parse_position.rs @@ -27,7 +27,7 @@ pub enum PositionError { /// The suffix (string after the range section) conflicts with the estimated position. #[error("Suffix has unknown sequence")] SuffixVerifyError, - /// The range section contains an asterisk, which is not allowed. + /// An asterisk was found in the range section. This implies the pattern matches across multiple fields. #[error("Asterisk is not allowed in range section")] AsteriskInRange, /// Range section is empty. This pattern does not match any label. From adff9117f62745c912cc46de645ee090e61d581d Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Sun, 14 Jun 2026 18:54:37 +0900 Subject: [PATCH 3/4] plural --- crates/jlabel-question/src/parse_position.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/jlabel-question/src/parse_position.rs b/crates/jlabel-question/src/parse_position.rs index 879fdf6..44d4f8f 100644 --- a/crates/jlabel-question/src/parse_position.rs +++ b/crates/jlabel-question/src/parse_position.rs @@ -27,7 +27,7 @@ pub enum PositionError { /// The suffix (string after the range section) conflicts with the estimated position. #[error("Suffix has unknown sequence")] SuffixVerifyError, - /// An asterisk was found in the range section. This implies the pattern matches across multiple fields. + /// Asterisk(s) was/were found in the range section. This implies the pattern matches across multiple fields. #[error("Asterisk is not allowed in range section")] AsteriskInRange, /// Range section is empty. This pattern does not match any label. From 04ea8502ffec6ef7d60121e79850b428174c2252 Mon Sep 17 00:00:00 2001 From: femshima <49227365+femshima@users.noreply.github.com> Date: Sun, 14 Jun 2026 19:14:09 +0900 Subject: [PATCH 4/4] plural --- crates/jlabel-question/src/parse_position.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/jlabel-question/src/parse_position.rs b/crates/jlabel-question/src/parse_position.rs index 44d4f8f..19270c9 100644 --- a/crates/jlabel-question/src/parse_position.rs +++ b/crates/jlabel-question/src/parse_position.rs @@ -27,7 +27,7 @@ pub enum PositionError { /// The suffix (string after the range section) conflicts with the estimated position. #[error("Suffix has unknown sequence")] SuffixVerifyError, - /// Asterisk(s) was/were found in the range section. This implies the pattern matches across multiple fields. + /// An asterisk(s) was found in the range section. This implies the pattern matches across multiple fields. #[error("Asterisk is not allowed in range section")] AsteriskInRange, /// Range section is empty. This pattern does not match any label.