Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): Ensure reprovided types unify #2051

Merged
merged 1 commit into from
Mar 2, 2024
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
9 changes: 9 additions & 0 deletions compiler/src/typed/typemod.re
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,15 @@ let rec type_module = (~toplevel=false, anchor, env, statements) => {
| Some(_) => failwith("Impossible: invalid alias")
| None => Ident.create(name.txt)
};
let type_ =
switch (type_path) {
| PExternal(_) => {
...type_,
type_manifest:
Some(Ctype.newconstr(type_path, type_.type_params)),
}
| PIdent(_) => type_
};
([TSigType(id, type_, TRecNot), ...sigs], stmts);
| PProvideException({name: {txt: IdentName(name)}, alias, loc}) =>
let ext = Typetexp.find_exception(env, loc, IdentName(name));
Expand Down
5 changes: 5 additions & 0 deletions compiler/test/input/reprovideTypeUnifyA.gr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module ReprovideTypeUnifyA

from "./reprovideTypeUnifyB" include ReprovideTypeUnifyB
use ReprovideTypeUnifyB.{ type T, a }
print(a == { x: 1, })
6 changes: 6 additions & 0 deletions compiler/test/input/reprovideTypeUnifyB.gr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module ReprovideTypeUnifyB

from "./reprovideTypeUnifyC" include ReprovideTypeUnifyC
use ReprovideTypeUnifyC.{ type T }
let a = { x: 1, }
provide { type T, a }
5 changes: 5 additions & 0 deletions compiler/test/input/reprovideTypeUnifyC.gr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module ReprovideTypeUnifyC

provide record T {
x: Number,
}
6 changes: 6 additions & 0 deletions compiler/test/suites/provides.re
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe("provides", ({test, testSkip}) => {
);
let assertCompileError = makeCompileErrorRunner(test);
let assertRun = makeRunner(test_or_skip);
let assertFileRun = makeFileRunner(test_or_skip);
let assertRunError = makeErrorRunner(test_or_skip);
let assertHasWasmExport = (name, prog, expectedExports) => {
test(
Expand Down Expand Up @@ -249,4 +250,9 @@ describe("provides", ({test, testSkip}) => {
"module Test; enum T { A }; provide let a = A; provide { type T }",
[("GRAIN$EXPORT$a", Binaryen.Export.external_global)],
);
assertFileRun(
"issue_1886_type_reprovided_unify",
"reprovideTypeUnifyA",
"true\n",
);
});
Loading