rescript-compiler
rescript-compiler copied to clipboard
"Illegal recursive module reference" error does not report the location when module alias is used
Version: 9.1.4 Live example: https://rescript-lang.org/try?code=LYewJgrgNgpgBAJxgYzgQTgLjgbwL5wC86AUCQIYB2YcAQlriXHKJLOkaQcTky+NHgZiaEnhJA
Assume we have the following code:
module rec A : {} = A
and B : {
module A = A
} = {
module A = A
}
It fails with the "Illegal recursive module reference" error, which is good, but it does not report the location where the illegal reference happens:
FAILED: src/example.cmj
We've found a bug for you!
/home/foo/test8/src/example.res
Illegal recursive module reference
FAILED: cannot make progress due to previous errors.
When you try to compile the equivalent OCaml code, it correctly points out the location:
module rec A: sig end = A
and B: sig
module A = A
end = struct
module A = A
end
(* Line 4, characters 13-14: *)
(* Error: Illegal recursive module reference *)
UPDATE: interestingly, it does report the location when include is used instead of module alias:
module rec A : {} = A
and B : {
include module type of A
} = {
include A
}
// [E] Line 4, column 25:
// Illegal recursive module reference