Skip to content

Commit

Permalink
fix(compiler): Correct error message for unbound type variables (#1327)
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Jun 13, 2022
1 parent 75bbb93 commit 762362a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler/src/typed/typetexp.re
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,13 @@ let globalize_used_variables = (env, fixed) => {
try(r := [(loc, v, Tbl.find(name, type_variables^)), ...r^]) {
| Not_found =>
if (fixed && Btype.is_Tvar(repr(ty))) {
raise(Error(loc, env, Unbound_type_variable("'" ++ name)));
raise(
Error(
loc,
env,
Unbound_type_variable(Printf.sprintf("'%s'", name)),
),
);
};
let v2 = new_global_var();
r := [(loc, v, v2), ...r^];
Expand Down
7 changes: 7 additions & 0 deletions compiler/test/suites/types.re
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ describe("aliased types", ({test, testSkip}) => {
|},
"Type String is not compatible with type Number",
);
assertCompileError(
"err_type_alias_5",
{|
type Foo = List<a>
|},
"Unbound type parameter 'a'",
);
assertRun(
"import_type_alias_1",
{|
Expand Down

0 comments on commit 762362a

Please sign in to comment.