Skip to content

Commit ed894ae

Browse files
zthcknitt
andauthored
Editor: Fix issue where type arg ctx was not passed along properly (#7227)
* fix issue where type arg ctx was not passed along properly for inline recordds * changelog * Do not reformat changelog --------- Co-authored-by: Christoph Knittel <[email protected]>
1 parent 3500728 commit ed894ae

File tree

9 files changed

+61
-3
lines changed

9 files changed

+61
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
# 12.0.0-alpha.7 (Unreleased)
1414

15+
#### :bug: Bug fix
16+
17+
- Editor: Fix issue where completions would stop working in some scenarios with inline records. https://github.com/rescript-lang/rescript/pull/7227
18+
1519
#### :nail_care: Polish
1620

1721
- Add all standard CSS properties to `JsxDOMStyle`. https://github.com/rescript-lang/rescript/pull/7205

analysis/src/TypeUtils.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
646646
Toption (env, ExtractedType typ) ) ->
647647
if Debug.verbose () then
648648
print_endline "[nested]--> moving into option Some";
649-
typ |> resolveNested ~env ~full ~nested
649+
typ |> resolveNested ?typeArgContext ~env ~full ~nested
650650
| ( NVariantPayload {constructorName = "Some"; itemNum = 0},
651651
Toption (env, TypeExpr typ) ) ->
652652
if Debug.verbose () then
@@ -706,7 +706,8 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
706706
| Some {args = InlineRecord fields} when itemNum = 0 ->
707707
if Debug.verbose () then
708708
print_endline "[nested]--> found constructor (inline record)";
709-
TinlineRecord {env; fields} |> resolveNested ~env ~full ~nested
709+
TinlineRecord {env; fields}
710+
|> resolveNested ?typeArgContext ~env ~full ~nested
710711
| _ -> None)
711712
| ( NPolyvariantPayload {constructorName; itemNum},
712713
Tpolyvariant {env; constructors} ) -> (
@@ -725,7 +726,7 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
725726
|> Utils.Option.flatMap (fun (typ, typeArgContext) ->
726727
typ |> resolveNested ?typeArgContext ~env ~full ~nested)))
727728
| NArray, Tarray (env, ExtractedType typ) ->
728-
typ |> resolveNested ~env ~full ~nested
729+
typ |> resolveNested ?typeArgContext ~env ~full ~nested
729730
| NArray, Tarray (env, TypeExpr typ) ->
730731
typ
731732
|> extractType ~env ~package:full.package

tests/analysis_tests/tests/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module CatchResult = {
2+
@tag("ok")
3+
type t<'value> = | @as(true) Ok({value: 'value}) | @as(false) Error({errors: array<string>})
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
type someTyp = {test: bool}
2+
let catchResult = Support.CatchResult.Ok({
3+
value: {
4+
test: true,
5+
},
6+
})
7+
8+
// switch catchResult { | Ok({value: }) => ()
9+
// ^com

tests/analysis_tests/tests/src/expected/Completion.res.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,16 @@ Path T
20962096
"modulePath": "Type",
20972097
"filePath": "src/Completion.res"
20982098
}
2099+
}, {
2100+
"label": "TypeArgCtx",
2101+
"kind": 9,
2102+
"tags": [],
2103+
"detail": "module TypeArgCtx",
2104+
"documentation": null,
2105+
"data": {
2106+
"modulePath": "TypeArgCtx",
2107+
"filePath": "src/Completion.res"
2108+
}
20992109
}, {
21002110
"label": "TypeAtPosCompletion",
21012111
"kind": 9,

tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ Path CompletionSupport.TestComponent.make
7979
"modulePath": "Type",
8080
"filePath": "src/CompletionJsxProps.res"
8181
}
82+
}, {
83+
"label": "TypeArgCtx",
84+
"kind": 9,
85+
"tags": [],
86+
"detail": "module TypeArgCtx",
87+
"documentation": null,
88+
"data": {
89+
"modulePath": "TypeArgCtx",
90+
"filePath": "src/CompletionJsxProps.res"
91+
}
8292
}, {
8393
"label": "TypeAtPosCompletion",
8494
"kind": 9,

tests/analysis_tests/tests/src/expected/Support.res.txt

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Complete src/TypeArgCtx.res 7:36
2+
posCursor:[7:36] posNoWhite:[7:35] Found pattern:[7:26->7:39]
3+
Ppat_construct Ok:[7:26->7:28]
4+
posCursor:[7:36] posNoWhite:[7:35] Found pattern:[7:29->7:38]
5+
Completable: Cpattern Value[catchResult]->variantPayload::Ok($0), recordField(value)
6+
Package opens Pervasives.JsxModules.place holder
7+
ContextPath Value[catchResult]
8+
Path catchResult
9+
[{
10+
"label": "{}",
11+
"kind": 22,
12+
"tags": [],
13+
"detail": "someTyp",
14+
"documentation": {"kind": "markdown", "value": "```rescript\ntype someTyp = {test: bool}\n```"},
15+
"sortText": "A",
16+
"insertText": "{$0}",
17+
"insertTextFormat": 2
18+
}]
19+

0 commit comments

Comments
 (0)