Skip to content

Commit 0ec00ae

Browse files
committed
destructure record rest elements - fixes #8311
1 parent d680426 commit 0ec00ae

53 files changed

Lines changed: 576 additions & 133 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

analysis/reanalyze/src/DeadValue.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ let collectPattern ~config ~refs :
228228
fun super self pat ->
229229
let posFrom = pat.Typedtree.pat_loc.loc_start in
230230
(match pat.pat_desc with
231-
| Typedtree.Tpat_record (cases, _clodsedFlag) ->
231+
| Typedtree.Tpat_record (cases, _clodsedFlag, _rest) ->
232232
cases
233233
|> List.iter (fun (_loc, {Types.lbl_loc = {loc_start = posTo}}, _pat, _) ->
234234
if !Config.analyzeTypes then

analysis/src/CompletionFrontEnd.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
514514
(NPolyvariantPayload {itemNum = 0; constructorName = txt}
515515
:: patternPath)
516516
?contextPath p
517-
| Ppat_record (fields, _) ->
517+
| Ppat_record (fields, _, _rest) ->
518518
Ext_list.iter fields (fun {lid = fname; x = p} ->
519519
match fname with
520520
| {Location.txt = Longident.Lident fname} ->

analysis/src/CompletionPatterns.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ and traversePattern (pat : Parsetree.pattern) ~patternPath ~locHasCursor
102102
[Completable.NTupleItem {itemNum}] @ patternPath)
103103
~resultFromFoundItemNum:(fun itemNum ->
104104
[Completable.NTupleItem {itemNum = itemNum + 1}] @ patternPath)
105-
| Ppat_record ([], _) ->
105+
| Ppat_record ([], _, _rest) ->
106106
(* Empty fields means we're in a record body `{}`. Complete for the fields. *)
107107
someIfHasCursor
108108
("", [Completable.NRecordBody {seenFields = []}] @ patternPath)
109109
"Ppat_record(empty)"
110-
| Ppat_record (fields, _) -> (
110+
| Ppat_record (fields, _, _rest) -> (
111111
let fieldWithCursor = ref None in
112112
let fieldWithPatHole = ref None in
113113
Ext_list.iter fields (fun {lid = fname; x = f} ->

analysis/src/DumpAst.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ let rec printPattern pattern ~pos ~indentation =
9999
| None -> ""
100100
| Some pat -> "," ^ printPattern pat ~pos ~indentation)
101101
^ ")"
102-
| Ppat_record (fields, _) ->
102+
| Ppat_record (fields, _, _rest) ->
103103
"Ppat_record(\n"
104104
^ addIndentation (indentation + 1)
105105
^ "fields:\n"

analysis/src/Hint.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let inlay ~path ~pos ~maxLength ~debug =
4343
let rec processPattern (pat : Parsetree.pattern) =
4444
match pat.ppat_desc with
4545
| Ppat_tuple pl -> pl |> List.iter processPattern
46-
| Ppat_record (fields, _) ->
46+
| Ppat_record (fields, _, _rest) ->
4747
Ext_list.iter fields (fun {x = p} -> processPattern p)
4848
| Ppat_array fields -> fields |> List.iter processPattern
4949
| Ppat_var {loc} -> push loc Type

analysis/src/ProcessCmt.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ let rec forStructureItem ~(env : SharedTypes.Env.t) ~(exported : Exported.t)
512512
| Tpat_tuple pats | Tpat_array pats | Tpat_construct (_, _, pats) ->
513513
pats |> List.iter (fun p -> handlePattern [] p)
514514
| Tpat_or (p, _, _) -> handlePattern [] p
515-
| Tpat_record (items, _) ->
515+
| Tpat_record (items, _, _rest) ->
516516
items |> List.iter (fun (_, _, p, _) -> handlePattern [] p)
517517
| Tpat_variant (_, Some p, _) -> handlePattern [] p
518518
| Tpat_variant (_, None, _) | Tpat_any | Tpat_constant _ -> ()

analysis/src/ProcessExtra.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ let pat ~(file : File.t) ~env ~extra (iter : Tast_iterator.iterator)
391391
in
392392
(* Log.log("Entering pattern " ++ Utils.showLocation(pat_loc)); *)
393393
(match pattern.pat_desc with
394-
| Tpat_record (items, _) ->
394+
| Tpat_record (items, _, _rest) ->
395395
addForRecord ~env ~extra ~recordType:pattern.pat_type items
396396
| Tpat_construct (lident, constructor, _) ->
397397
addForConstructor ~env ~extra pattern.pat_type lident constructor

analysis/src/SemanticTokens.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ let command ~debug ~emitter ~path =
231231
| Ppat_construct ({txt = Lident ("true" | "false")}, _) ->
232232
(* Don't emit true or false *)
233233
Ast_iterator.default_iterator.pat iterator p
234-
| Ppat_record (cases, _) ->
234+
| Ppat_record (cases, _, _rest) ->
235235
Ext_list.iter cases (fun {lid = label} ->
236236
emitter |> emitRecordLabel ~label ~debug);
237237
Ast_iterator.default_iterator.pat iterator p

analysis/src/SignatureHelp.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
664664
match tupleItemWithCursor with
665665
| None -> -1
666666
| Some i -> i)
667-
| `ConstructorPat (_, {ppat_desc = Ppat_record (fields, _)}) -> (
667+
| `ConstructorPat (_, {ppat_desc = Ppat_record (fields, _, _rest)})
668+
-> (
668669
let fieldNameWithCursor =
669670
fields
670671
|> List.find_map

analysis/src/Xform.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module IfThenElse = struct
7676
in
7777
match listToPat ~itemToPat items with
7878
| None -> None
79-
| Some patItems -> Some (mkPat (Ppat_record (patItems, Closed))))
79+
| Some patItems -> Some (mkPat (Ppat_record (patItems, Closed, None))))
8080
| Pexp_record (_, Some _) -> None
8181
| _ -> None
8282

0 commit comments

Comments
 (0)