Skip to content

Commit 0223607

Browse files
committed
Fix issue with recursive modules and uncurried.
Fixes #6555
1 parent d2ccc4e commit 0223607

File tree

5 files changed

+296
-11
lines changed

5 files changed

+296
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
1313
# 11.0.1 (Unreleased)
1414

15+
#### :bug: Bug Fix
16+
- Fix issue with recursive modules and uncurried. https://github.com/rescript-lang/rescript-compiler/pull/6575
17+
1518
# 11.0.0
1619

1720
No changes compared to rc.9.

jscomp/ml/transl_recmodule.ml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,22 @@ let init_shape modl =
5151
match sg with
5252
| [] -> []
5353
| Sig_value (id, { val_kind = Val_reg; val_type = ty }) :: rem ->
54+
let is_function t =
55+
Ast_uncurried_utils.typeIsUncurriedFun t || match t.desc with
56+
| Tarrow _ -> true
57+
| _ -> false in
5458
let init_v =
5559
match Ctype.expand_head env ty with
56-
| { desc = Tarrow (_, _, _, _) } ->
57-
Const_pointer
58-
( 0,
59-
Pt_constructor
60-
{
61-
name = "Function";
62-
const = cstr_const;
63-
non_const = cstr_non_const;
64-
attrs = [];
65-
} )
60+
| t when is_function t ->
61+
Const_pointer
62+
( 0,
63+
Pt_constructor
64+
{
65+
name = "Function";
66+
const = cstr_const;
67+
non_const = cstr_non_const;
68+
attrs = [];
69+
} )
6670
| { desc = Tconstr (p, _, _) } when Path.same p Predef.path_lazy_t ->
6771
Const_pointer
6872
( 1,

jscomp/test/build.ninja

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

jscomp/test/recmodule.js

Lines changed: 207 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/recmodule.res

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
type params = {id: string}
2+
type req = {params: params}
3+
4+
module Entity = {
5+
type light = {
6+
id: string,
7+
name: string,
8+
}
9+
}
10+
11+
module UseCase = {
12+
module type Layer = {
13+
let getLight: string => promise<unit>
14+
}
15+
16+
module type Deps = {
17+
let presentLight: Entity.light => promise<unit>
18+
}
19+
20+
module MakeLayer = (Deps: Deps): Layer => {
21+
let getLight = id => {
22+
Deps.presentLight({
23+
id,
24+
name: "Light 1",
25+
})
26+
}
27+
}
28+
}
29+
30+
module Adapter = {
31+
module type Layer = {
32+
let handleGetLight: req => promise<unit>
33+
let presentLight: Entity.light => promise<unit>
34+
}
35+
36+
module type Deps = {
37+
let presentJson: ('a, ~status: int) => promise<unit>
38+
}
39+
40+
module MakeLayer = (Deps: Deps, UC: UseCase.Layer): Layer => {
41+
let presentLight = light => light->Deps.presentJson(~status=200)
42+
43+
let handleGetLight = req => {
44+
UC.getLight(req.params.id)
45+
}
46+
}
47+
}
48+
49+
module Infra = {
50+
module type Layer = {
51+
let presentJson: ('a, ~status: int) => promise<unit>
52+
let routes: unit => array<(string, req => promise<unit>)>
53+
}
54+
55+
module type Deps = {
56+
let handleGetLight: req => promise<unit>
57+
}
58+
59+
module MakeLayer = (Deps: Deps): Layer => {
60+
let presentJson = (json, ~status) => assert false
61+
62+
let routes = () => [("/lights", Deps.handleGetLight)]
63+
}
64+
}
65+
66+
module App = {
67+
module rec I: Infra.Layer = Infra.MakeLayer(A)
68+
and A: Adapter.Layer = Adapter.MakeLayer(I, U)
69+
and U: UseCase.Layer = UseCase.MakeLayer(A)
70+
}

0 commit comments

Comments
 (0)