try
let e = type_expr ctx e (WithType t) in
AbstractCast.cast_or_unify_raise ctx t e e.epos
with Error(l,p) when (match l with Call_error _ | Module_not_found _ -> false | _ -> true) ->
raise (WithTypeError (l,p))
which is called by:
try
let e = type_against t e in
(e,opt) :: loop el args
with
WithTypeError (ul,p)->
if opt then
let e_def = skip name ul t p in
(e_def,true) :: loop (e :: el) args
else
arg_error ul name false p | Error (Custom msg,_) as e -> prerr_endline ("TROUGH typer:593 " ^ msg); raise e
In my case, here what happened:
an optional argument contained a yet-unloaded module
the expression was typed, which meant the module was loaded + built macro run
it returned some correct expression but with some error into it (a double declared field in a structure)
this raised a correct error when typing it
... which was captured + ignored by unify_call_args
which resulted in a half typed module doing some very strange things type wise, without any idea why
I think that we need to make sure that the error occurred inside the expression itself. That could be hacky but we could look if the expression (recursively) contains the position reported by the error before turning it into an WithTypeError, or letting it pass either.
Typer.unif_call_args' does the following:
which is called by:
In my case, here what happened:
I think that we need to make sure that the error occurred inside the expression itself. That could be hacky but we could look if the expression (recursively) contains the position reported by the error before turning it into an WithTypeError, or letting it pass either.