diff --git a/CHANGELOG.md b/CHANGELOG.md index 267347ad3a..118b62ee92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/compiler/syntax/src/res_outcome_printer.ml b/compiler/syntax/src/res_outcome_printer.ml index 1deeecc89e..f6fd5aec84 100644 --- a/compiler/syntax/src/res_outcome_printer.ml +++ b/compiler/syntax/src/res_outcome_printer.ml @@ -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; + result) labels types) in Doc.indent (Doc.concat [Doc.line; package]) diff --git a/tests/analysis_tests/tests/src/CreateInterface.res b/tests/analysis_tests/tests/src/CreateInterface.res index 71843a7f35..845067e1eb 100644 --- a/tests/analysis_tests/tests/src/CreateInterface.res +++ b/tests/analysis_tests/tests/src/CreateInterface.res @@ -171,3 +171,24 @@ module ComponentWithPolyProp = {
} } + +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 => { + let module(M) = id + + { + cmp: M.cmp->Belt.Id.getCmpInternal, + set: Belt.Set.make(~id), + array: [], + } + } +} diff --git a/tests/analysis_tests/tests/src/expected/CreateInterface.res.txt b/tests/analysis_tests/tests/src/expected/CreateInterface.res.txt index 0d6d809a9c..19567088a3 100644 --- a/tests/analysis_tests/tests/src/expected/CreateInterface.res.txt +++ b/tests/analysis_tests/tests/src/expected/CreateInterface.res.txt @@ -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> +}