From 2f1f6141a9eb9ac75a302d8570e49f9fa6566cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Fri, 22 Aug 2025 11:05:54 +0200 Subject: [PATCH 1/3] Fix interface creation of functions with upper bounded polymorphic args --- compiler/syntax/src/res_outcome_printer.ml | 13 ------------ .../tests/src/CreateInterface.res | 21 +++++++++++++++++++ .../src/expected/CompletionAttributes.res.txt | 18 ++++++++++++++++ .../src/expected/CreateInterface.res.txt | 10 +++++++++ 4 files changed, 49 insertions(+), 13 deletions(-) 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/CompletionAttributes.res.txt b/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt index 1c7c3fb9df..796d18957c 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt @@ -24,6 +24,12 @@ Resolved opens 1 Stdlib "tags": [], "detail": "Package", "documentation": null + }, { + "label": "./CreateInterface.cmt", + "kind": 4, + "tags": [], + "detail": "Local file", + "documentation": null }, { "label": "./test.json", "kind": 4, @@ -191,6 +197,12 @@ Resolved opens 1 Stdlib "tags": [], "detail": "Package", "documentation": null + }, { + "label": "./CreateInterface.cmt", + "kind": 4, + "tags": [], + "detail": "Local file", + "documentation": null }, { "label": "./test.json", "kind": 4, @@ -216,6 +228,12 @@ Resolved opens 1 Stdlib "tags": [], "detail": "Package", "documentation": null + }, { + "label": "./CreateInterface.cmt", + "kind": 4, + "tags": [], + "detail": "Local file", + "documentation": null }, { "label": "./test.json", "kind": 4, 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 +} From cfcd99b3af96aa578dd5a0c767384ef19ba58e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Fri, 22 Aug 2025 11:53:20 +0200 Subject: [PATCH 2/3] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 02f50011a45f014adc2195713c226bff7655587b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Fri, 22 Aug 2025 12:14:04 +0200 Subject: [PATCH 3/3] Update CompletionAttributes.res.txt --- .../src/expected/CompletionAttributes.res.txt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt b/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt index 796d18957c..1c7c3fb9df 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt @@ -24,12 +24,6 @@ Resolved opens 1 Stdlib "tags": [], "detail": "Package", "documentation": null - }, { - "label": "./CreateInterface.cmt", - "kind": 4, - "tags": [], - "detail": "Local file", - "documentation": null }, { "label": "./test.json", "kind": 4, @@ -197,12 +191,6 @@ Resolved opens 1 Stdlib "tags": [], "detail": "Package", "documentation": null - }, { - "label": "./CreateInterface.cmt", - "kind": 4, - "tags": [], - "detail": "Local file", - "documentation": null }, { "label": "./test.json", "kind": 4, @@ -228,12 +216,6 @@ Resolved opens 1 Stdlib "tags": [], "detail": "Package", "documentation": null - }, { - "label": "./CreateInterface.cmt", - "kind": 4, - "tags": [], - "detail": "Local file", - "documentation": null }, { "label": "./test.json", "kind": 4,