unified: More $children fixes

Some nodes with a single child (arguably redundant to do, but I think
it's nice to have the types be consistent), and also an instance of
ensuring that all branches of a `choice` expose consistent field names.
This commit is contained in:
Taus
2026-05-12 14:15:36 +00:00
parent 0499932ba0
commit 15d84b3e53
2 changed files with 6 additions and 7 deletions

View File

@@ -452,7 +452,7 @@ module.exports = grammar({
optional(sep1Opt(field("element", $.tuple_type_item), ",")),
")"
),
alias($._parenthesized_type, $.tuple_type_item)
field("element", alias($._parenthesized_type, $.tuple_type_item))
),
tuple_type_item: ($) =>
prec(
@@ -791,13 +791,13 @@ module.exports = grammar({
),
value_argument_label: ($) =>
prec.left(
choice(
field("name", choice(
$.simple_identifier,
// We don't rely on $._contextual_simple_identifier here because
// these don't usually fall into that category.
alias("if", $.simple_identifier),
alias("switch", $.simple_identifier)
)
))
),
value_argument: ($) =>
prec.left(
@@ -1094,7 +1094,7 @@ module.exports = grammar({
$.statements,
optional("fallthrough")
),
switch_pattern: ($) => alias($._binding_pattern_with_expr, $.pattern),
switch_pattern: ($) => field("pattern", alias($._binding_pattern_with_expr, $.pattern)),
do_statement: ($) =>
prec.right(PRECS["do"], seq("do", $._block, repeat(field("catch", $.catch_block)))),
catch_block: ($) =>

View File

@@ -559,7 +559,7 @@ named:
switch_entry:
$children+: [default_keyword, expression, modifiers, statements, switch_pattern, where_keyword]
switch_pattern:
$children: pattern
pattern: pattern
switch_statement:
entry*: switch_entry
expr: expression
@@ -579,7 +579,6 @@ named:
name*: simple_identifier
value+: expression
tuple_type:
$children?: tuple_type_item
element*: tuple_type_item
tuple_type_item:
$children?: [dictionary_type, existential_type, opaque_type, wildcard_pattern]
@@ -627,7 +626,7 @@ named:
type_modifiers?: type_modifiers
value?: expression
value_argument_label:
$children: simple_identifier
name: simple_identifier
value_arguments:
argument*: value_argument
value_binding_pattern: