Skip to content

Commit ef77a31

Browse files
authored
fix(compiler): Correct Include_module_name_mismatch error (#2261)
1 parent eb85692 commit ef77a31

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

compiler/src/typed/typemod.re

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module String = Misc.Stdlib.String;
2727
type error =
2828
| Cannot_apply(module_type)
2929
| Not_included(list(Includemod.error))
30-
| Include_module_name_mismatch(string, string)
30+
| Include_module_name_mismatch(string, string, string)
3131
| Cannot_eliminate_dependency(module_type)
3232
| Signature_expected
3333
| Structure_expected(module_type)
@@ -83,7 +83,11 @@ let include_module = (env, sod) => {
8383
Error(
8484
sod.pinc_module.loc,
8585
env,
86-
Include_module_name_mismatch(sod.pinc_module.txt, mod_name),
86+
Include_module_name_mismatch(
87+
sod.pinc_path.txt,
88+
sod.pinc_module.txt,
89+
mod_name,
90+
),
8791
),
8892
);
8993
};
@@ -1095,12 +1099,13 @@ let report_error = ppf =>
10951099
Includemod.report_error,
10961100
errs,
10971101
)
1098-
| Include_module_name_mismatch(provided_name, actual_name) =>
1102+
| Include_module_name_mismatch(path, provided_name, actual_name) =>
10991103
fprintf(
11001104
ppf,
1101-
"This statement includes module %s, but the file at the path defines module %s. Did you mean `include %s as %s`?",
1105+
"This statement includes module %s, but the file at the path defines module %s. Did you mean `from \"%s\" include %s as %s`?",
11021106
provided_name,
11031107
actual_name,
1108+
path,
11041109
actual_name,
11051110
provided_name,
11061111
)

compiler/src/typed/typemod.rei

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ open Typedtree;
55
type error =
66
| Cannot_apply(module_type)
77
| Not_included(list(Includemod.error))
8-
| Include_module_name_mismatch(string, string)
8+
| Include_module_name_mismatch(string, string, string)
99
| Cannot_eliminate_dependency(module_type)
1010
| Signature_expected
1111
| Structure_expected(module_type)

compiler/test/suites/includes.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ describe("includes", ({test, testSkip}) => {
106106
);
107107
assertCompileError(
108108
"include_module_error",
109-
"from \"provideAll\" include Foo; Foo.foo",
110-
"This statement includes module Foo, but the file at the path defines module ProvideAll. Did you mean `include ProvideAll as Foo`?",
109+
{|from "provideAll" include Foo; Foo.foo|},
110+
{|This statement includes module Foo, but the file at the path defines module ProvideAll. Did you mean `from "provideAll.gr" include ProvideAll as Foo`?|},
111111
);
112112
/* use well-formedness errors */
113113
assertCompileError(

0 commit comments

Comments
 (0)