Skip to content

Commit 51cc49d

Browse files
committed
fix issue where type arg ctx wasnt passed along
1 parent 76adc98 commit 51cc49d

File tree

7 files changed

+57
-3
lines changed

7 files changed

+57
-3
lines changed

analysis/src/TypeUtils.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
660660
Toption (env, ExtractedType typ) ) ->
661661
if Debug.verbose () then
662662
print_endline "[nested]--> moving into option Some";
663-
typ |> resolveNested ~env ~full ~nested
663+
typ |> resolveNested ?typeArgContext ~env ~full ~nested
664664
| ( NVariantPayload {constructorName = "Some"; itemNum = 0},
665665
Toption (env, TypeExpr typ) ) ->
666666
if Debug.verbose () then
@@ -720,7 +720,8 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
720720
| Some {args = InlineRecord fields} when itemNum = 0 ->
721721
if Debug.verbose () then
722722
print_endline "[nested]--> found constructor (inline record)";
723-
TinlineRecord {env; fields} |> resolveNested ~env ~full ~nested
723+
TinlineRecord {env; fields}
724+
|> resolveNested ?typeArgContext ~env ~full ~nested
724725
| _ -> None)
725726
| ( NPolyvariantPayload {constructorName; itemNum},
726727
Tpolyvariant {env; constructors} ) -> (
@@ -739,7 +740,7 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
739740
|> Utils.Option.flatMap (fun (typ, typeArgContext) ->
740741
typ |> resolveNested ?typeArgContext ~env ~full ~nested)))
741742
| NArray, Tarray (env, ExtractedType typ) ->
742-
typ |> resolveNested ~env ~full ~nested
743+
typ |> resolveNested ?typeArgContext ~env ~full ~nested
743744
| NArray, Tarray (env, TypeExpr typ) ->
744745
typ
745746
|> extractType ~env ~package:full.package

analysis/tests/src/Support.res

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+
}

analysis/tests/src/TypeArgCtx.res

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

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,16 @@ Path T
18491849
"modulePath": "TableclothMap",
18501850
"filePath": "src/Completion.res"
18511851
}
1852+
}, {
1853+
"label": "TypeArgCtx",
1854+
"kind": 9,
1855+
"tags": [],
1856+
"detail": "module TypeArgCtx",
1857+
"documentation": null,
1858+
"data": {
1859+
"modulePath": "TypeArgCtx",
1860+
"filePath": "src/Completion.res"
1861+
}
18521862
}, {
18531863
"label": "TypeAtPosCompletion",
18541864
"kind": 9,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ Path CompletionSupport.TestComponent.make
7272
"modulePath": "TableclothMap",
7373
"filePath": "src/CompletionJsxProps.res"
7474
}
75+
}, {
76+
"label": "TypeArgCtx",
77+
"kind": 9,
78+
"tags": [],
79+
"detail": "module TypeArgCtx",
80+
"documentation": null,
81+
"data": {
82+
"modulePath": "TypeArgCtx",
83+
"filePath": "src/CompletionJsxProps.res"
84+
}
7585
}, {
7686
"label": "TypeAtPosCompletion",
7787
"kind": 9,

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

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
Resolved opens 1 pervasives
8+
ContextPath Value[catchResult]
9+
Path catchResult
10+
[{
11+
"label": "{}",
12+
"kind": 22,
13+
"tags": [],
14+
"detail": "someTyp",
15+
"documentation": {"kind": "markdown", "value": "```rescript\ntype someTyp = {test: bool}\n```"},
16+
"sortText": "A",
17+
"insertText": "{$0}",
18+
"insertTextFormat": 2
19+
}]
20+

0 commit comments

Comments
 (0)