HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.14k stars 653 forks source link

Error swallowed by unify_call_args #5837

Open ncannasse opened 7 years ago

ncannasse commented 7 years ago

Typer.unif_call_args' does the following:

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:

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.

Simn commented 7 years ago

See #5885