Skip to content

Commit 4c3203c

Browse files
authored
fix(compiler): Ensure reprovided types unify (#2051)
1 parent 029059f commit 4c3203c

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

compiler/src/typed/typemod.re

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,15 @@ let rec type_module = (~toplevel=false, anchor, env, statements) => {
674674
| Some(_) => failwith("Impossible: invalid alias")
675675
| None => Ident.create(name.txt)
676676
};
677+
let type_ =
678+
switch (type_path) {
679+
| PExternal(_) => {
680+
...type_,
681+
type_manifest:
682+
Some(Ctype.newconstr(type_path, type_.type_params)),
683+
}
684+
| PIdent(_) => type_
685+
};
677686
([TSigType(id, type_, TRecNot), ...sigs], stmts);
678687
| PProvideException({name: {txt: IdentName(name)}, alias, loc}) =>
679688
let ext = Typetexp.find_exception(env, loc, IdentName(name));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module ReprovideTypeUnifyA
2+
3+
from "./reprovideTypeUnifyB" include ReprovideTypeUnifyB
4+
use ReprovideTypeUnifyB.{ type T, a }
5+
print(a == { x: 1, })
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module ReprovideTypeUnifyB
2+
3+
from "./reprovideTypeUnifyC" include ReprovideTypeUnifyC
4+
use ReprovideTypeUnifyC.{ type T }
5+
let a = { x: 1, }
6+
provide { type T, a }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module ReprovideTypeUnifyC
2+
3+
provide record T {
4+
x: Number,
5+
}

compiler/test/suites/provides.re

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("provides", ({test, testSkip}) => {
1313
);
1414
let assertCompileError = makeCompileErrorRunner(test);
1515
let assertRun = makeRunner(test_or_skip);
16+
let assertFileRun = makeFileRunner(test_or_skip);
1617
let assertRunError = makeErrorRunner(test_or_skip);
1718
let assertHasWasmExport = (name, prog, expectedExports) => {
1819
test(
@@ -249,4 +250,9 @@ describe("provides", ({test, testSkip}) => {
249250
"module Test; enum T { A }; provide let a = A; provide { type T }",
250251
[("GRAIN$EXPORT$a", Binaryen.Export.external_global)],
251252
);
253+
assertFileRun(
254+
"issue_1886_type_reprovided_unify",
255+
"reprovideTypeUnifyA",
256+
"true\n",
257+
);
252258
});

0 commit comments

Comments
 (0)