From 46027de719930b227b90332f373a119f334cdf45 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Thu, 2 Jan 2020 15:11:02 +0100 Subject: [PATCH] Proper error with location --- src/passes/3-self_ast_simplified/literals.ml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/passes/3-self_ast_simplified/literals.ml b/src/passes/3-self_ast_simplified/literals.ml index 7950aeae2..dfe3cac4a 100644 --- a/src/passes/3-self_ast_simplified/literals.ml +++ b/src/passes/3-self_ast_simplified/literals.ml @@ -2,15 +2,26 @@ open Ast_simplified open Trace open Proto_alpha_utils +module Errors = struct + let bad_literal_address s_addr loc () = + let title = (thunk ("Badly formatted address \""^s_addr^"\"")) in + let message () = "" in + let data = [ + ("location" , fun () -> Format.asprintf "%a" Location.pp loc) + ] in + error ~data title message () +end +open Errors + let peephole_expression : expression -> expression result = fun e -> let return expression = ok { e with expression } in match e.expression with - | E_literal (Literal_address s) as e -> ( + | E_literal (Literal_address s) as l -> ( let open Memory_proto_alpha in let%bind (_contract:Protocol.Alpha_context.Contract.t) = - Trace.trace_alpha_tzresult (simple_error ("address \""^s^"\" is not a valid address")) @@ + Trace.trace_alpha_tzresult (bad_literal_address s e.location) @@ Protocol.Alpha_context.Contract.of_b58check s in - return e + return l ) | E_constant (C_BIG_MAP_LITERAL , lst) -> ( let%bind elt =