Fix #13185: Type-level module alias for functor parameter accepted#13192
Fix #13185: Type-level module alias for functor parameter accepted#13192Octachron merged 3 commits intoocaml:trunkfrom
Conversation
typing/typemod.ml
Outdated
| (Style.as_inline_code path) p | ||
| | Cannot_alias p -> | ||
| Location.errorf ~loc | ||
| "Cannot alias the module %a, it is a functor argument" |
There was a problem hiding this comment.
I would propose to merge the two clauses into The functor argument %a cannot be aliased.
There was a problem hiding this comment.
Functor arguments like %a cannot be aliased?
Changes
Outdated
| (Jan Midtgaard, review by Antonin Décimo, Sébastien Hinderer, and | ||
| David Allsopp) | ||
|
|
||
| - #13185: Type-level module alias for functor parameter accepted |
There was a problem hiding this comment.
The changes entry might mislead readers that missed the fact that we are describing the bug and not the fix.
Maybe reject type-level module aliases on functor parameters?
| | Mty_alias p -> | ||
| if Env.is_functor_arg p env then | ||
| raise (Error (pmd.pmd_loc, env, Cannot_alias p)); | ||
| Mp_absent |
There was a problem hiding this comment.
I have been wondering if we want to the check this property in transl_modtype when creating the alias, but I think that raising the error here gives a better location : the whole module M = Aliased binding rather than just Aliased.
Octachron
left a comment
There was a problem hiding this comment.
I agree that it is better to raise an error early for those impossible signatures, and the small implementation size is nice.
Add a new error message when a functor parameter is aliased inside a signature.
Fixes #13185.