Commit 928f5069 authored by Jeff Smits's avatar Jeff Smits

Fix bug in ConsMatch: Cons and Nil should be handled separately

parent a0910531
......@@ -175,6 +175,9 @@ pub enum Strategy {
}
impl Strategy {
/// Gives back the String constructor if the first possibly failing thing the strategy really
/// does is match on that constructor. "Cons" and "Nil" are not returned, since lists need to
/// be handled specially
fn matches_cons(str: &ctree::Strategy) -> Option<String> {
use ctree::Strategy::*;
match *str {
......@@ -200,6 +203,8 @@ impl Strategy {
use ctree::Term::Anno;
match *trm {
As(_, ref t) => Self::matches_cons_preterm(&**t),
Op(ref c, ref r) if c == "Cons" && r.len() == 2 => None,
Op(ref c, ref r) if c == "Nil" && r.is_empty() => None,
Op(ref s, _) => Some(s.clone()),
Explode(Anno(ref pt,_), _) => match **pt {
Str(ref s) => Some(s.clone()),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment