Skip to content

Commit d7cab95

Browse files
committed
Backward-compatible check for optional fields.
1 parent bb28463 commit d7cab95

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

analysis/tests/src/expected/CompletionExpressions.res.txt

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -471,27 +471,13 @@ posCursor:[108:57] posNoWhite:[108:56] Found expr:[108:11->108:60]
471471
Pexp_apply ...[108:11->108:42] (...[108:43->108:60])
472472
Completable: Cexpression CArgument Value[fnTakingRecordWithOptionalField]($0)->recordField(someOptField)
473473
[{
474-
"label": "None",
475-
"kind": 4,
476-
"tags": [],
477-
"detail": "bool",
478-
"documentation": null
479-
}, {
480-
"label": "Some(_)",
481-
"kind": 4,
482-
"tags": [],
483-
"detail": "bool",
484-
"documentation": null,
485-
"insertText": "Some(${1:_})",
486-
"insertTextFormat": 2
487-
}, {
488-
"label": "Some(true)",
474+
"label": "true",
489475
"kind": 4,
490476
"tags": [],
491477
"detail": "bool",
492478
"documentation": null
493479
}, {
494-
"label": "Some(false)",
480+
"label": "false",
495481
"kind": 4,
496482
"tags": [],
497483
"detail": "bool",
@@ -771,7 +757,7 @@ Completable: Cpath Value[fff].someOpt
771757
"label": "someOptField",
772758
"kind": 5,
773759
"tags": [],
774-
"detail": "someOptField: option<bool>\n\ntype recordWithOptionalField = {\n someField: int,\n someOptField?: bool,\n}",
760+
"detail": "someOptField?: bool\n\ntype recordWithOptionalField = {\n someField: int,\n someOptField?: bool,\n}",
775761
"documentation": null
776762
}]
777763

analysis/tests/src/expected/Destructuring.res.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ Completable: Cpattern Value[x]->recordBody
6868
"detail": "someField: int\n\nrecordWithOptField",
6969
"documentation": null
7070
}, {
71-
"label": "someOptField",
71+
"label": "?someOptField",
7272
"kind": 5,
7373
"tags": [],
74-
"detail": "someOptField: option<bool>\n\nrecordWithOptField",
75-
"documentation": null
74+
"detail": "?someOptField: option<bool>\n\nrecordWithOptField",
75+
"documentation": {"kind": "markdown", "value": "someOptField is an optional field, and needs to be destructured using '?'."}
7676
}]
7777

analysis/vendor/res_outcome_printer/res_parsetree_viewer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ let isIfLetExpr expr =
348348
let rec hasOptionalAttribute attrs =
349349
match attrs with
350350
| [] -> false
351-
| ({Location.txt = "res.optional"}, _) :: _ -> true
351+
| ({Location.txt = "ns.optional" | "res.optional"}, _) :: _ -> true
352352
| _ :: attrs -> hasOptionalAttribute attrs
353353

354354
let hasAttributes attrs =

0 commit comments

Comments
 (0)