Skip to content

Showcase stack overflow bug with polyvariants #851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Proper default for `"uncurried"` in V11 projects. https://github.com/rescript-lang/rescript-vscode/pull/867
- Treat `result` type as a proper built in type. https://github.com/rescript-lang/rescript-vscode/pull/860
- Fix infinite loop when resolving inferred completions when several values in scope has the same name. https://github.com/rescript-lang/rescript-vscode/pull/869
- Fix crash when trying to print recursive polymorphic variants without a concrete definition. https://github.com/rescript-lang/rescript-vscode/pull/851

#### :nail_care: Polish

Expand Down
1 change: 1 addition & 0 deletions analysis/src/PrintType.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let printExpr ?(lineWidth = 60) typ =
Printtyp.reset_names ();
Printtyp.reset_and_mark_loops typ;
Res_doc.toString ~width:lineWidth
(Res_outcome_printer.printOutTypeDoc (Printtyp.tree_of_typexp false typ))

Expand Down
14 changes: 14 additions & 0 deletions analysis/tests/src/PolyRec.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let rec sum = x =>
switch x {
| #Leaf => 0
| #Node(value, left, right) => value + left->sum + right->sum
}

let myTree = #Node(
1,
#Node(2, #Node(4, #Leaf, #Leaf), #Node(6, #Leaf, #Leaf)),
#Node(3, #Node(5, #Leaf, #Leaf), #Node(7, #Leaf, #Leaf)),
)

let () = myTree->sum->Js.log
// ^hov
12 changes: 6 additions & 6 deletions analysis/tests/src/expected/CompletionPattern.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Path f
"label": "optThird",
"kind": 5,
"tags": [],
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
"documentation": null
}, {
"label": "nest",
Expand All @@ -150,7 +150,7 @@ Path f
"label": "optThird",
"kind": 5,
"tags": [],
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
"documentation": null
}, {
"label": "nest",
Expand Down Expand Up @@ -189,7 +189,7 @@ Path z
"label": "optThird",
"kind": 5,
"tags": [],
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
"documentation": null
}]

Expand Down Expand Up @@ -267,7 +267,7 @@ Path f
"label": "optThird",
"kind": 5,
"tags": [],
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
"documentation": null
}, {
"label": "nest",
Expand Down Expand Up @@ -360,7 +360,7 @@ Path z
"label": "optThird",
"kind": 5,
"tags": [],
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
"documentation": null
}, {
"label": "nest",
Expand Down Expand Up @@ -451,7 +451,7 @@ Path b
"label": "optThird",
"kind": 5,
"tags": [],
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
"documentation": null
}, {
"label": "nest",
Expand Down
4 changes: 2 additions & 2 deletions analysis/tests/src/expected/Hover.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ Hover src/Hover.res 106:21
{"contents": {"kind": "markdown", "value": "```rescript\nint\n```"}}

Hover src/Hover.res 116:16
{"contents": {"kind": "markdown", "value": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```\n\n---\n\n```\n \n```\n```rescript\ntype AA.cond<'a> = 'a\n constraint 'a = [< #str(string)]\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C110%2C2%5D)\n"}}
{"contents": {"kind": "markdown", "value": "```rescript\nAA.cond<([< #str(string)] as 'a)> => AA.cond<'a>\n```\n\n---\n\n```\n \n```\n```rescript\ntype AA.cond<'a> = 'a\n constraint 'a = [< #str(string)]\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C110%2C2%5D)\n"}}

Hover src/Hover.res 119:25
{"contents": {"kind": "markdown", "value": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```\n\n---\n\n```\n \n```\n```rescript\ntype AA.cond<'a> = 'a\n constraint 'a = [< #str(string)]\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C110%2C2%5D)\n"}}
{"contents": {"kind": "markdown", "value": "```rescript\nAA.cond<([< #str(string)] as 'a)> => AA.cond<'a>\n```\n\n---\n\n```\n \n```\n```rescript\ntype AA.cond<'a> = 'a\n constraint 'a = [< #str(string)]\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C110%2C2%5D)\n"}}

Hover src/Hover.res 122:3
Nothing at that position. Now trying to use completion.
Expand Down
3 changes: 3 additions & 0 deletions analysis/tests/src/expected/PolyRec.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hover src/PolyRec.res 12:10
{"contents": {"kind": "markdown", "value": "```rescript\n([#Leaf | #Node(int, 'a, 'a)] as 'a)\n```"}}