fix(lib): prevent wildcards from incorrectly marking child patterns as infallible

When a pattern appears under a wildcard parent (like "(_ (expr))"), we
were incorrectly marking it as infallible. The parent_pattern_guaranteed
flag only means the pattern will match after finding the right wildcard
parent, not that any wildcard parent will work.
This commit is contained in:
Amaan Qureshi 2025-01-03 22:31:50 -05:00
parent a7e6d01144
commit 5f379da544
2 changed files with 31 additions and 1 deletions

View file

@ -3004,7 +3004,7 @@ bool ts_query__step_is_fallible(
return (
next_step->depth != PATTERN_DONE_MARKER &&
next_step->depth > step->depth &&
!next_step->parent_pattern_guaranteed
(!next_step->parent_pattern_guaranteed || step->symbol == WILDCARD_SYMBOL)
);
}