diff --git a/CHANGELOG.md b/CHANGELOG.md index 4355c3866d..94f28013b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - 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 - Fix ppx resolution with package inside monorepo. https://github.com/rescript-lang/rescript/pull/7776 - Fix 'Unbound module type' errors that occurred when trying to async import modules. https://github.com/rescript-lang/rescript/pull/7783 +- Fix creating interface for functions with upper bounded polymorphic args. https://github.com/rescript-lang/rescript/pull/7786 #### :memo: Documentation diff --git a/compiler/syntax/src/res_outcome_printer.ml b/compiler/syntax/src/res_outcome_printer.ml index e8b97c7815..1deeecc89e 100644 --- a/compiler/syntax/src/res_outcome_printer.ml +++ b/compiler/syntax/src/res_outcome_printer.ml @@ -123,19 +123,6 @@ let rec print_out_type_doc (out_type : Outcometree.out_type) = (if non_gen then Doc.text "_" else Doc.nil); Doc.lbracket; Doc.indent (Doc.concat [opening; print_out_variant out_variant]); - (match labels with - | None | Some [] -> Doc.nil - | Some tags -> - Doc.group - (Doc.concat - [ - Doc.space; - Doc.join ~sep:Doc.space - (List.map - (fun lbl -> - Printer.print_ident_like ~allow_uident:true lbl) - tags); - ])); Doc.soft_line; Doc.rbracket; ]) diff --git a/tests/analysis_tests/tests/src/CreateInterface.res b/tests/analysis_tests/tests/src/CreateInterface.res index 3f7ab03d48..71843a7f35 100644 --- a/tests/analysis_tests/tests/src/CreateInterface.res +++ b/tests/analysis_tests/tests/src/CreateInterface.res @@ -150,3 +150,24 @@ type record = { @as("foo_bar") fooBar: int } + +type poly = [#a(int) | #b(string) | #c(float)] + +type red = [#Ruby | #Redwood | #Rust] +type blue = [#Sapphire | #Neon | #Navy] +type color = [red | blue | #Papayawhip] + +external upperBound: ([< #d | #e | #f]) => unit = "myexternal" +external lowerBound: ([> #d | #e | #f]) => unit = "myexternal" + +module ComponentWithPolyProp = { + @react.component + let make = (~size=#large) => { + let className = switch size { + | #large => "text-lg" + | #small => "text-sm" + } + +
+ } +} diff --git a/tests/analysis_tests/tests/src/expected/CreateInterface.res.txt b/tests/analysis_tests/tests/src/expected/CreateInterface.res.txt index 700f3a599d..0d6d809a9c 100644 --- a/tests/analysis_tests/tests/src/expected/CreateInterface.res.txt +++ b/tests/analysis_tests/tests/src/expected/CreateInterface.res.txt @@ -114,4 +114,14 @@ type record = { @as("foo_bar") fooBar: int } +type poly = [#a(int) | #b(string) | #c(float)] +type red = [#Ruby | #Redwood | #Rust] +type blue = [#Sapphire | #Neon | #Navy] +type color = [red | blue | #Papayawhip] +external upperBound: ([< #d | #e | #f]) => unit = "myexternal" +external lowerBound: ([> #d | #e | #f]) => unit = "myexternal" +module ComponentWithPolyProp: { + @react.component + let make: (~size: [< #large | #small]=?) => Jsx.element +}