diff --git a/CHANGELOG.md b/CHANGELOG.md index a6a7c9e50c..8dc29eb3f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ # 12.0.0-alpha.7 (Unreleased) +#### :bug: Bug fix + +- Editor: Fix issue where completions would stop working in some scenarios with inline records. https://github.com/rescript-lang/rescript/pull/7227 + #### :nail_care: Polish - Add all standard CSS properties to `JsxDOMStyle`. https://github.com/rescript-lang/rescript/pull/7205 diff --git a/analysis/src/TypeUtils.ml b/analysis/src/TypeUtils.ml index 6f476e8356..491df9accb 100644 --- a/analysis/src/TypeUtils.ml +++ b/analysis/src/TypeUtils.ml @@ -646,7 +646,7 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx Toption (env, ExtractedType typ) ) -> if Debug.verbose () then print_endline "[nested]--> moving into option Some"; - typ |> resolveNested ~env ~full ~nested + typ |> resolveNested ?typeArgContext ~env ~full ~nested | ( NVariantPayload {constructorName = "Some"; itemNum = 0}, Toption (env, TypeExpr typ) ) -> if Debug.verbose () then @@ -706,7 +706,8 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx | Some {args = InlineRecord fields} when itemNum = 0 -> if Debug.verbose () then print_endline "[nested]--> found constructor (inline record)"; - TinlineRecord {env; fields} |> resolveNested ~env ~full ~nested + TinlineRecord {env; fields} + |> resolveNested ?typeArgContext ~env ~full ~nested | _ -> None) | ( NPolyvariantPayload {constructorName; itemNum}, Tpolyvariant {env; constructors} ) -> ( @@ -725,7 +726,7 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx |> Utils.Option.flatMap (fun (typ, typeArgContext) -> typ |> resolveNested ?typeArgContext ~env ~full ~nested))) | NArray, Tarray (env, ExtractedType typ) -> - typ |> resolveNested ~env ~full ~nested + typ |> resolveNested ?typeArgContext ~env ~full ~nested | NArray, Tarray (env, TypeExpr typ) -> typ |> extractType ~env ~package:full.package diff --git a/tests/analysis_tests/tests/package-lock.json b/tests/analysis_tests/tests/package-lock.json index 7a51892b94..775904830a 100644 --- a/tests/analysis_tests/tests/package-lock.json +++ b/tests/analysis_tests/tests/package-lock.json @@ -33,6 +33,7 @@ } }, "../../..": { + "name": "rescript", "version": "12.0.0-alpha.7", "hasInstallScript": true, "license": "SEE LICENSE IN LICENSE", diff --git a/tests/analysis_tests/tests/src/Support.res b/tests/analysis_tests/tests/src/Support.res new file mode 100644 index 0000000000..a0ce4ef412 --- /dev/null +++ b/tests/analysis_tests/tests/src/Support.res @@ -0,0 +1,4 @@ +module CatchResult = { + @tag("ok") + type t<'value> = | @as(true) Ok({value: 'value}) | @as(false) Error({errors: array}) +} diff --git a/tests/analysis_tests/tests/src/TypeArgCtx.res b/tests/analysis_tests/tests/src/TypeArgCtx.res new file mode 100644 index 0000000000..fc4c0270d7 --- /dev/null +++ b/tests/analysis_tests/tests/src/TypeArgCtx.res @@ -0,0 +1,9 @@ +type someTyp = {test: bool} +let catchResult = Support.CatchResult.Ok({ + value: { + test: true, + }, +}) + +// switch catchResult { | Ok({value: }) => () +// ^com diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index 51cf7966ac..b87cd58ad2 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -2096,6 +2096,16 @@ Path T "modulePath": "Type", "filePath": "src/Completion.res" } + }, { + "label": "TypeArgCtx", + "kind": 9, + "tags": [], + "detail": "module TypeArgCtx", + "documentation": null, + "data": { + "modulePath": "TypeArgCtx", + "filePath": "src/Completion.res" + } }, { "label": "TypeAtPosCompletion", "kind": 9, diff --git a/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt b/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt index 8e745b7073..5cbc61be30 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt @@ -79,6 +79,16 @@ Path CompletionSupport.TestComponent.make "modulePath": "Type", "filePath": "src/CompletionJsxProps.res" } + }, { + "label": "TypeArgCtx", + "kind": 9, + "tags": [], + "detail": "module TypeArgCtx", + "documentation": null, + "data": { + "modulePath": "TypeArgCtx", + "filePath": "src/CompletionJsxProps.res" + } }, { "label": "TypeAtPosCompletion", "kind": 9, diff --git a/tests/analysis_tests/tests/src/expected/Support.res.txt b/tests/analysis_tests/tests/src/expected/Support.res.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/analysis_tests/tests/src/expected/TypeArgCtx.res.txt b/tests/analysis_tests/tests/src/expected/TypeArgCtx.res.txt new file mode 100644 index 0000000000..62940941cb --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/TypeArgCtx.res.txt @@ -0,0 +1,19 @@ +Complete src/TypeArgCtx.res 7:36 +posCursor:[7:36] posNoWhite:[7:35] Found pattern:[7:26->7:39] +Ppat_construct Ok:[7:26->7:28] +posCursor:[7:36] posNoWhite:[7:35] Found pattern:[7:29->7:38] +Completable: Cpattern Value[catchResult]->variantPayload::Ok($0), recordField(value) +Package opens Pervasives.JsxModules.place holder +ContextPath Value[catchResult] +Path catchResult +[{ + "label": "{}", + "kind": 22, + "tags": [], + "detail": "someTyp", + "documentation": {"kind": "markdown", "value": "```rescript\ntype someTyp = {test: bool}\n```"}, + "sortText": "A", + "insertText": "{$0}", + "insertTextFormat": 2 + }] +