From 2608db9fd98a75409c3b2536342aa942b3bf0407 Mon Sep 17 00:00:00 2001 From: Taus Date: Fri, 8 May 2026 21:10:58 +0000 Subject: [PATCH] unified: Prevent field bleed-through from `_if_let_binding` Same procedure as before -- we change the anonymous node to a named node, and the problem magically goes away. --- unified/extractor/tree-sitter-swift/grammar.js | 4 ++-- unified/extractor/tree-sitter-swift/node-types.yml | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/unified/extractor/tree-sitter-swift/grammar.js b/unified/extractor/tree-sitter-swift/grammar.js index 4d20431a070..22b5af18ffa 100644 --- a/unified/extractor/tree-sitter-swift/grammar.js +++ b/unified/extractor/tree-sitter-swift/grammar.js @@ -1041,8 +1041,8 @@ module.exports = grammar({ ) ), if_condition: ($) => - choice($._if_let_binding, $.expression, $.availability_condition), - _if_let_binding: ($) => + choice($.if_let_binding, $.expression, $.availability_condition), + if_let_binding: ($) => seq( $._direct_or_indirect_binding, optional(seq($._equal_sign, $.expression)), diff --git a/unified/extractor/tree-sitter-swift/node-types.yml b/unified/extractor/tree-sitter-swift/node-types.yml index 7ac626492d4..7b97a68afde 100644 --- a/unified/extractor/tree-sitter-swift/node-types.yml +++ b/unified/extractor/tree-sitter-swift/node-types.yml @@ -235,7 +235,9 @@ named: identifier: $children+: simple_identifier if_condition: - $children*: [availability_condition, expression, pattern, type, type_annotation, user_type, value_binding_pattern, where_clause, wildcard_pattern] + $children: [availability_condition, expression, if_let_binding] + if_let_binding: + $children*: [expression, pattern, type, type_annotation, user_type, value_binding_pattern, where_clause, wildcard_pattern] bound_identifier?: simple_identifier if_statement: $children*: [else, if_statement, statements]