diff --git a/src/asm/matcher/mod.rs b/src/asm/matcher/mod.rs index d70a5b82..747d610a 100644 --- a/src/asm/matcher/mod.rs +++ b/src/asm/matcher/mod.rs @@ -433,8 +433,20 @@ pub fn match_instr( .collect::>(); - // Identical duplicate matches are already sorted consecutively - matches.dedup_by(|a, b| a.is_same(b)); + // Remove duplicate matches + for i in (0..matches.len()).rev() + { + let mut duplicate = false; + for j in 0..i + { + duplicate |= matches[i].is_same(&matches[j]); + } + + if duplicate + { + matches.remove(i); + } + } // Calculate recursive "exact" pattern-part count for diff --git a/tests/issue204/ok.asm b/tests/issue204/ok.asm new file mode 100644 index 00000000..aac05781 --- /dev/null +++ b/tests/issue204/ok.asm @@ -0,0 +1,21 @@ +#ruledef foo +{ + f{e:u4} => e + f{e:u4}+{m:foo} => e @ m +} + +#ruledef bar +{ + |{f:foo}| => 0xa @ f + ){f:foo}( => 0xb @ f + ]{f:foo}[ => 0xc @ f + ({f:foo}) => 0xd @ f + [{f:foo}] => 0xe @ f +} + +f1+f2+f3+f4 ; = 0x1234 +|f1+f2+f3+f4| ; = 0xa1234 +)f1+f2+f3+f4( ; = 0xb1234 +]f1+f2+f3+f4[ ; = 0xc1234 +(f1+f2+f3+f4) ; = 0xd1234 +[f1+f2+f3+f4] ; = 0xe1234 \ No newline at end of file