From b508aac1c45be0a3189b2a5fd604991aca3f7d33 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 8 May 2022 11:34:02 +0200 Subject: [PATCH 1/3] Add example of poly variant duplication. See https://github.com/rescript-lang/rescript-vscode/issues/302 --- analysis/tests/src/Hover.res | 12 ++++++++++++ analysis/tests/src/expected/Hover.res.txt | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/analysis/tests/src/Hover.res b/analysis/tests/src/Hover.res index 04e6297e4..af1c263d6 100644 --- a/analysis/tests/src/Hover.res +++ b/analysis/tests/src/Hover.res @@ -96,3 +96,15 @@ let _get = r => r.f +. r.i let withAs = (~xx as yyy) => yyy + 1 // ^hov + +module AA = { + type cond<'a> = [< #str(string)] as 'a + type t<'a> = {b: cond<'a>} + let fun = b => {b: b} +} + +let typeOk = AA.fun +// ^hov + +let typeDuplicate = AA.fun +// ^hov \ No newline at end of file diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index fd3d7454d..cb4439801 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -58,3 +58,9 @@ Hover tests/src/Hover.res 93:25 Hover tests/src/Hover.res 96:21 {"contents": "```rescript\nint\n```"} +Hover tests/src/Hover.res 105:6 +{"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.t<[< #str(string)]>\n```"} + +Hover tests/src/Hover.res 108:24 +{"contents": "```rescript\nAA.cond<\n [< #str(string) & (string) & (string)],\n> => AA.t<[< #str(string) & (string) & (string)]>\n```"} + From 63815a93f3c8dcc1814e45faad5ca52e7711419e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 8 May 2022 11:42:54 +0200 Subject: [PATCH 2/3] tweak test --- analysis/tests/src/Hover.res | 11 ++++++----- analysis/tests/src/expected/Hover.res.txt | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/analysis/tests/src/Hover.res b/analysis/tests/src/Hover.res index af1c263d6..c35b05f46 100644 --- a/analysis/tests/src/Hover.res +++ b/analysis/tests/src/Hover.res @@ -99,12 +99,13 @@ let withAs = (~xx as yyy) => yyy + 1 module AA = { type cond<'a> = [< #str(string)] as 'a - type t<'a> = {b: cond<'a>} - let fun = b => {b: b} + let fun = (b: cond<_>) => true ? b : b } -let typeOk = AA.fun -// ^hov +let funAlias = AA.fun + +let typeOk = funAlias +// ^hov let typeDuplicate = AA.fun -// ^hov \ No newline at end of file +// ^hov diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index cb4439801..9bddf3c92 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -58,9 +58,9 @@ Hover tests/src/Hover.res 93:25 Hover tests/src/Hover.res 96:21 {"contents": "```rescript\nint\n```"} -Hover tests/src/Hover.res 105:6 -{"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.t<[< #str(string)]>\n```"} +Hover tests/src/Hover.res 106:16 +{"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```"} -Hover tests/src/Hover.res 108:24 -{"contents": "```rescript\nAA.cond<\n [< #str(string) & (string) & (string)],\n> => AA.t<[< #str(string) & (string) & (string)]>\n```"} +Hover tests/src/Hover.res 109:25 +{"contents": "```rescript\nAA.cond<\n [< #str(string) & (string) & (string) & (string)],\n> => AA.cond<\n [< #str(string) & (string) & (string) & (string)],\n>\n```"} From 607b09898d38d5127fc0072b1acbee2c578833f3 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 8 May 2022 12:58:00 +0200 Subject: [PATCH 3/3] Fix issue with duplication. Fix https://github.com/rescript-lang/rescript-vscode/issues/302 --- analysis/src/ProcessCmt.ml | 4 ++-- analysis/tests/src/Hover.res | 6 +++--- analysis/tests/src/expected/Fragment.res.txt | 2 +- analysis/tests/src/expected/Hover.res.txt | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/analysis/src/ProcessCmt.ml b/analysis/src/ProcessCmt.ml index e9ba99a04..dd14dfb67 100644 --- a/analysis/src/ProcessCmt.ml +++ b/analysis/src/ProcessCmt.ml @@ -916,8 +916,8 @@ struct | Texp_open (_, _path, _ident, _) -> Hashtbl.add extra.opens eloc () | _ -> ()); match expression.exp_desc with - | Texp_ident (path, {txt; loc}, {val_type}) -> - addForLongident (Some (val_type, Value)) path txt loc + | Texp_ident (path, {txt; loc}, _) -> + addForLongident (Some (expression.exp_type, Value)) path txt loc | Texp_record {fields} -> addForRecord expression.exp_type (fields |> Array.to_list diff --git a/analysis/tests/src/Hover.res b/analysis/tests/src/Hover.res index c35b05f46..e0cbbf16a 100644 --- a/analysis/tests/src/Hover.res +++ b/analysis/tests/src/Hover.res @@ -99,13 +99,13 @@ let withAs = (~xx as yyy) => yyy + 1 module AA = { type cond<'a> = [< #str(string)] as 'a - let fun = (b: cond<_>) => true ? b : b + let fnnxx = (b: cond<_>) => true ? b : b } -let funAlias = AA.fun +let funAlias = AA.fnnxx let typeOk = funAlias // ^hov -let typeDuplicate = AA.fun +let typeDuplicate = AA.fnnxx // ^hov diff --git a/analysis/tests/src/expected/Fragment.res.txt b/analysis/tests/src/expected/Fragment.res.txt index e3ba9a7fa..9c9b80943 100644 --- a/analysis/tests/src/expected/Fragment.res.txt +++ b/analysis/tests/src/expected/Fragment.res.txt @@ -1,5 +1,5 @@ Hover tests/src/Fragment.res 6:19 -{"contents": "```rescript\n{\"children\": 'children} => 'children\n```"} +{"contents": "```rescript\nReact.component<{\"children\": React.element}>\n```\n\n```rescript\ntype component<'props> = componentLike<'props, element>\n```"} Hover tests/src/Fragment.res 9:56 null diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index 9bddf3c92..1e7b5331d 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -47,10 +47,10 @@ Hover tests/src/Hover.res 75:7 {"contents": "```rescript\nmodule A = {\n let x: int\n}\n```"} Hover tests/src/Hover.res 85:10 -{"contents": "```rescript\n{\"children\": React.element} => React.element\n```"} +{"contents": "```rescript\nReact.component<{\"children\": React.element}>\n```\n\n```rescript\ntype component<'props> = componentLike<'props, element>\n```"} Hover tests/src/Hover.res 88:10 -{"contents": "```rescript\n{\"children\": React.element} => React.element\n```"} +{"contents": "```rescript\nReact.component<{\"children\": React.element}>\n```\n\n```rescript\ntype component<'props> = componentLike<'props, element>\n```"} Hover tests/src/Hover.res 93:25 {"contents": "```rescript\nfloat\n```"} @@ -62,5 +62,5 @@ Hover tests/src/Hover.res 106:16 {"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```"} Hover tests/src/Hover.res 109:25 -{"contents": "```rescript\nAA.cond<\n [< #str(string) & (string) & (string) & (string)],\n> => AA.cond<\n [< #str(string) & (string) & (string) & (string)],\n>\n```"} +{"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```"}