Skip to content

Commit de25a65

Browse files
zthcristianoc
andauthored
Showcase stack overflow bug with polyvariants (#851)
* showcase stack overflow bug with polyvariants * Mark where the stack overflow happens. * try something * changelog * remove debug --------- Co-authored-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
1 parent e11dfe3 commit de25a65

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- Proper default for `"uncurried"` in V11 projects. https://github.com/rescript-lang/rescript-vscode/pull/867
2222
- Treat `result` type as a proper built in type. https://github.com/rescript-lang/rescript-vscode/pull/860
2323
- 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
24+
- Fix crash when trying to print recursive polymorphic variants without a concrete definition. https://github.com/rescript-lang/rescript-vscode/pull/851
2425

2526
#### :nail_care: Polish
2627

analysis/src/PrintType.ml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let printExpr ?(lineWidth = 60) typ =
22
Printtyp.reset_names ();
3+
Printtyp.reset_and_mark_loops typ;
34
Res_doc.toString ~width:lineWidth
45
(Res_outcome_printer.printOutTypeDoc (Printtyp.tree_of_typexp false typ))
56

analysis/tests/src/PolyRec.res

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
let rec sum = x =>
2+
switch x {
3+
| #Leaf => 0
4+
| #Node(value, left, right) => value + left->sum + right->sum
5+
}
6+
7+
let myTree = #Node(
8+
1,
9+
#Node(2, #Node(4, #Leaf, #Leaf), #Node(6, #Leaf, #Leaf)),
10+
#Node(3, #Node(5, #Leaf, #Leaf), #Node(7, #Leaf, #Leaf)),
11+
)
12+
13+
let () = myTree->sum->Js.log
14+
// ^hov

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Path f
129129
"label": "optThird",
130130
"kind": 5,
131131
"tags": [],
132-
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
132+
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
133133
"documentation": null
134134
}, {
135135
"label": "nest",
@@ -150,7 +150,7 @@ Path f
150150
"label": "optThird",
151151
"kind": 5,
152152
"tags": [],
153-
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
153+
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
154154
"documentation": null
155155
}, {
156156
"label": "nest",
@@ -189,7 +189,7 @@ Path z
189189
"label": "optThird",
190190
"kind": 5,
191191
"tags": [],
192-
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
192+
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
193193
"documentation": null
194194
}]
195195

@@ -267,7 +267,7 @@ Path f
267267
"label": "optThird",
268268
"kind": 5,
269269
"tags": [],
270-
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
270+
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
271271
"documentation": null
272272
}, {
273273
"label": "nest",
@@ -360,7 +360,7 @@ Path z
360360
"label": "optThird",
361361
"kind": 5,
362362
"tags": [],
363-
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
363+
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
364364
"documentation": null
365365
}, {
366366
"label": "nest",
@@ -451,7 +451,7 @@ Path b
451451
"label": "optThird",
452452
"kind": 5,
453453
"tags": [],
454-
"detail": "optThird: option<[#second(someRecord) | #first]>\n\nsomeRecord",
454+
"detail": "optThird: option<[#first | #second(someRecord)]>\n\nsomeRecord",
455455
"documentation": null
456456
}, {
457457
"label": "nest",

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ Hover src/Hover.res 106:21
7777
{"contents": {"kind": "markdown", "value": "```rescript\nint\n```"}}
7878

7979
Hover src/Hover.res 116:16
80-
{"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"}}
80+
{"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"}}
8181

8282
Hover src/Hover.res 119:25
83-
{"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"}}
83+
{"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"}}
8484

8585
Hover src/Hover.res 122:3
8686
Nothing at that position. Now trying to use completion.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Hover src/PolyRec.res 12:10
2+
{"contents": {"kind": "markdown", "value": "```rescript\n([#Leaf | #Node(int, 'a, 'a)] as 'a)\n```"}}
3+

0 commit comments

Comments
 (0)