Skip to content

Commit 1c9ebd7

Browse files
authored
Fix creating interface for functions with upper bounded polymorphic args (#7786)
* Fix interface creation of functions with upper bounded polymorphic args * Add CHANGELOG entry * Update CompletionAttributes.res.txt
1 parent cb59f21 commit 1c9ebd7

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
- Fix parse error with nested record types and attributes on the field name that has the nested record type. https://github.com/rescript-lang/rescript/pull/7781
4141
- Fix ppx resolution with package inside monorepo. https://github.com/rescript-lang/rescript/pull/7776
4242
- Fix 'Unbound module type' errors that occurred when trying to async import modules. https://github.com/rescript-lang/rescript/pull/7783
43+
- Fix creating interface for functions with upper bounded polymorphic args. https://github.com/rescript-lang/rescript/pull/7786
4344

4445
#### :nail_care: Polish
4546

compiler/syntax/src/res_outcome_printer.ml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,6 @@ let rec print_out_type_doc (out_type : Outcometree.out_type) =
123123
(if non_gen then Doc.text "_" else Doc.nil);
124124
Doc.lbracket;
125125
Doc.indent (Doc.concat [opening; print_out_variant out_variant]);
126-
(match labels with
127-
| None | Some [] -> Doc.nil
128-
| Some tags ->
129-
Doc.group
130-
(Doc.concat
131-
[
132-
Doc.space;
133-
Doc.join ~sep:Doc.space
134-
(List.map
135-
(fun lbl ->
136-
Printer.print_ident_like ~allow_uident:true lbl)
137-
tags);
138-
]));
139126
Doc.soft_line;
140127
Doc.rbracket;
141128
])

tests/analysis_tests/tests/src/CreateInterface.res

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,24 @@ type record = {
150150
@as("foo_bar")
151151
fooBar: int
152152
}
153+
154+
type poly = [#a(int) | #b(string) | #c(float)]
155+
156+
type red = [#Ruby | #Redwood | #Rust]
157+
type blue = [#Sapphire | #Neon | #Navy]
158+
type color = [red | blue | #Papayawhip]
159+
160+
external upperBound: ([< #d | #e | #f]) => unit = "myexternal"
161+
external lowerBound: ([> #d | #e | #f]) => unit = "myexternal"
162+
163+
module ComponentWithPolyProp = {
164+
@react.component
165+
let make = (~size=#large) => {
166+
let className = switch size {
167+
| #large => "text-lg"
168+
| #small => "text-sm"
169+
}
170+
171+
<div className />
172+
}
173+
}

tests/analysis_tests/tests/src/expected/CreateInterface.res.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,14 @@ type record = {
114114
@as("foo_bar")
115115
fooBar: int
116116
}
117+
type poly = [#a(int) | #b(string) | #c(float)]
118+
type red = [#Ruby | #Redwood | #Rust]
119+
type blue = [#Sapphire | #Neon | #Navy]
120+
type color = [red | blue | #Papayawhip]
121+
external upperBound: ([< #d | #e | #f]) => unit = "myexternal"
122+
external lowerBound: ([> #d | #e | #f]) => unit = "myexternal"
123+
module ComponentWithPolyProp: {
124+
@react.component
125+
let make: (~size: [< #large | #small]=?) => Jsx.element
126+
}
117127

0 commit comments

Comments
 (0)