Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4270,17 +4270,30 @@ if none @is_async {
}

(array_pattern
(_)@pat
[
(_)
(subscript_expression
index:(number)@subidx
)
]@pat
)@array_pat {
node @pat.comp_index
; There’s a `(subscript_expression … index:(number)@…)` stanza above that also
; creates the `comp_index` and its `push_symbol` attribute.
let is_number_subscript = (not (is-null @subidx))

if (not is_number_subscript) {
node @pat.comp_index
}

; propagate lexical scope
edge @pat.lexical_scope -> @array_pat.lexical_scope

; propagate cotype components
edge @pat.cotype -> @pat.comp_index
;
attr (@pat.comp_index) push_symbol = (named-child-index @pat)
if (not is_number_subscript) {
attr (@pat.comp_index) push_symbol = (named-child-index @pat)
}
edge @pat.comp_index -> @array_pat.indexable

; propagate defs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const items = [13, 37];
[items[0], items[1]] = [items[1], items[0]];
Loading