Skip to content

Commit 762362a

Browse files
authored
fix(compiler): Correct error message for unbound type variables (#1327)
1 parent 75bbb93 commit 762362a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/src/typed/typetexp.re

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,13 @@ let globalize_used_variables = (env, fixed) => {
457457
try(r := [(loc, v, Tbl.find(name, type_variables^)), ...r^]) {
458458
| Not_found =>
459459
if (fixed && Btype.is_Tvar(repr(ty))) {
460-
raise(Error(loc, env, Unbound_type_variable("'" ++ name)));
460+
raise(
461+
Error(
462+
loc,
463+
env,
464+
Unbound_type_variable(Printf.sprintf("'%s'", name)),
465+
),
466+
);
461467
};
462468
let v2 = new_global_var();
463469
r := [(loc, v, v2), ...r^];

compiler/test/suites/types.re

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ describe("aliased types", ({test, testSkip}) => {
110110
|},
111111
"Type String is not compatible with type Number",
112112
);
113+
assertCompileError(
114+
"err_type_alias_5",
115+
{|
116+
type Foo = List<a>
117+
|},
118+
"Unbound type parameter 'a'",
119+
);
113120
assertRun(
114121
"import_type_alias_1",
115122
{|

0 commit comments

Comments
 (0)