diff --git a/spec/compiler/build_tables/rule_transitions_spec.cpp b/spec/compiler/build_tables/rule_transitions_spec.cpp index b31343e8..54e2b26a 100644 --- a/spec/compiler/build_tables/rule_transitions_spec.cpp +++ b/spec/compiler/build_tables/rule_transitions_spec.cpp @@ -141,6 +141,28 @@ describe("rule transitions", []() { }) }}))); }); + + describe("regression tests (somewhat redundant, should maybe be deleted later)", []() { + it("handles sequences that start with repeating characters", [&]() { + auto rule = seq({ + choice({ + repeat(character({ '"' }, false)), + blank(), + }), + character('"'), + }); + + AssertThat(rule_transitions(rule), Equals(transition_map({ + { character({ '"' }, false), seq({ + choice({ + repeat(character({ '"' }, false)), + blank(), + }), + character('"'), }) }, + { character('"'), blank() }, + }))); + }); + }); }); describe("checking if rules can be blank", [&]() { diff --git a/src/compiler/rules/character.cpp b/src/compiler/rules/character.cpp index 728623d8..400743db 100644 --- a/src/compiler/rules/character.cpp +++ b/src/compiler/rules/character.cpp @@ -54,6 +54,7 @@ namespace tree_sitter { bool Character::operator==(const Rule &rule) const { const Character *other = dynamic_cast(&rule); if (!other) return false; + if (other->sign != sign) return false; auto size = matches.size(); if (other->matches.size() != size) return false; for (int i = 0; i < size; i++) @@ -71,6 +72,7 @@ namespace tree_sitter { string Character::to_string() const { string prefix("#";