From 0c8a8e415d947d2504b0ecf12cf11c67ad65386d Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Wed, 7 Feb 2024 19:26:16 +0100 Subject: [PATCH] print expected $type before typing We usually want to see the value it initially has without any inference from the typing --- src/typing/typer.ml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/typing/typer.ml b/src/typing/typer.ml index 8307365974f..c3dbc68d239 100644 --- a/src/typing/typer.ml +++ b/src/typing/typer.ml @@ -1740,13 +1740,19 @@ and type_call_builtin ctx e el mode with_type p = | TFun signature -> type_bind ctx e signature args p | _ -> raise Exit) | (EConst (Ident "$type"),_) , e1 :: el -> - let e1 = type_expr ctx e1 with_type in - let s = s_type (print_context()) e1.etype in - let s = match el with + let expected = match el with | [EConst (Ident "_"),_] -> - Printf.sprintf "%s (expected: %s)" s (WithType.to_string with_type) + Some (WithType.to_string with_type) | _ -> + None + in + let e1 = type_expr ctx e1 with_type in + let s = s_type (print_context()) e1.etype in + let s = match expected with + | None -> s + | Some s_expected -> + Printf.sprintf "%s (expected: %s)" s s_expected in warning ctx WInfo s e1.epos; e1