diff --git a/src/atom/parsers.rs b/src/atom/parsers.rs index 8da8203..c609a1c 100644 --- a/src/atom/parsers.rs +++ b/src/atom/parsers.rs @@ -185,6 +185,12 @@ impl<'a> Parseable<'a, &'a str> for Slot { sub, operator, }) + .verify_output(|slot| { + matches!( + (&slot.primary(), &slot.operator()), + (Some(_) | None, Some(_)) | (Some(_), None) + ) + }) } } @@ -420,9 +426,9 @@ mod test { #[test] fn test_empty_slot() { - let it = InputIter::new("foo/bar:="); + let it = InputIter::new("=dev-ml/uucp-17*:"); - Atom::parser().check_finished(it).unwrap(); + assert!(Atom::parser().check_finished(it).is_err()); } #[test] @@ -494,4 +500,11 @@ mod test { assert!(Cpv::parser().parse_finished(it).is_err()); } + + #[test] + fn test_empty_slot_with_operator() { + let it = InputIter::new("foo/bar:="); + + Atom::parser().check_finished(it).unwrap(); + } }