Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#### :bug: Bug fix

- Fix generation of interfaces for module types containing multiple type constraints. https://github.com/rescript-lang/rescript/pull/7825

#### :memo: Documentation

#### :nail_care: Polish
Expand Down
20 changes: 12 additions & 8 deletions compiler/syntax/src/res_outcome_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,18 @@ let rec print_out_type_doc (out_type : Outcometree.out_type) =
Doc.join ~sep:Doc.line
((List.map2 [@doesNotRaise])
(fun lbl typ ->
Doc.concat
[
Doc.text
(if i.contents > 0 then "and type " else "with type ");
Doc.text lbl;
Doc.text " = ";
print_out_type_doc typ;
])
let result =
Doc.concat
[
Doc.text
(if i.contents > 0 then "and type " else "with type ");
Doc.text lbl;
Doc.text " = ";
print_out_type_doc typ;
]
in
incr i;
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this incr i, i.contents was always 0

result)
labels types)
in
Doc.indent (Doc.concat [Doc.line; package])
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 @@ -171,3 +171,24 @@ module ComponentWithPolyProp = {
<div className />
}
}

module OrderedSet = {
type t<'a, 'identity> = {
cmp: ('a, 'a) => int,
set: Belt.Set.t<'a, 'identity>,
array: array<'a>,
}

let make = (
type value identity,
~id: module(Belt.Id.Comparable with type t = value and type identity = identity),
): t<value, identity> => {
let module(M) = id

{
cmp: M.cmp->Belt.Id.getCmpInternal,
set: Belt.Set.make(~id),
array: [],
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,12 @@ module ComponentWithPolyProp: {
@react.component
let make: (~size: [< #large | #small]=?) => Jsx.element
}
module OrderedSet: {
type t<'a, 'identity> = {
cmp: ('a, 'a) => int,
set: Belt.Set.t<'a, 'identity>,
array: array<'a>,
}
let make: (~id: module(Belt.Id.Comparable with type identity = 'a and type t = 'b)) => t<'b, 'a>
}

Loading