Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -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

Expand Down
13 changes: 0 additions & 13 deletions compiler/syntax/src/res_outcome_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any cases when we do want to print out the variant's labels/tags?

The code just above mentions syntax like [< #A | #B > #X #Y ], but this doesn't seem to be valid ReScript:

let opening =
match (closed, labels) with
| true, None -> (* [#A | #B] *) Doc.soft_line
| false, None ->
(* [> #A | #B] *)
Doc.concat [Doc.greater_than; Doc.line]
| true, Some [] ->
(* [< #A | #B] *)
Doc.concat [Doc.less_than; Doc.line]
| true, Some _ ->
(* [< #A | #B > #X #Y ] *)
Doc.concat [Doc.less_than; Doc.line]
| false, Some _ ->

| 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;
])
Expand Down
21 changes: 21 additions & 0 deletions tests/analysis_tests/tests/src/CreateInterface.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

<div className />
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions tests/analysis_tests/tests/src/expected/CreateInterface.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Loading