check ast_simplified address literals to be well formatted

This commit is contained in:
Lesenechal Remi 2020-01-02 15:01:55 +01:00
parent c0e959044b
commit 42cbabac69
2 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,7 @@
(libraries (libraries
simple-utils simple-utils
ast_simplified ast_simplified
proto-alpha-utils
) )
(preprocess (preprocess
(pps ppx_let bisect_ppx --conditional) (pps ppx_let bisect_ppx --conditional)

View File

@ -1,9 +1,17 @@
open Ast_simplified open Ast_simplified
open Trace open Trace
open Proto_alpha_utils
let peephole_expression : expression -> expression result = fun e -> let peephole_expression : expression -> expression result = fun e ->
let return expression = ok { e with expression } in let return expression = ok { e with expression } in
match e.expression with match e.expression with
| E_literal (Literal_address s) as e -> (
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")) @@
Protocol.Alpha_context.Contract.of_b58check s in
return e
)
| E_constant (C_BIG_MAP_LITERAL , lst) -> ( | E_constant (C_BIG_MAP_LITERAL , lst) -> (
let%bind elt = let%bind elt =
trace_option (simple_error "big_map literal expects a single parameter") @@ trace_option (simple_error "big_map literal expects a single parameter") @@