From df0dfb029b593617be82a2f0df6400ffcaaabfb9 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Wed, 11 Dec 2019 19:25:17 +0100 Subject: [PATCH] better error message when a contract in invalid --- src/main/compile/of_mini_c.ml | 8 ++++---- src/passes/9-self_michelson/helpers.ml | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/compile/of_mini_c.ml b/src/main/compile/of_mini_c.ml index 21dc59eba..0ed53895f 100644 --- a/src/main/compile/of_mini_c.ml +++ b/src/main/compile/of_mini_c.ml @@ -35,15 +35,15 @@ let aggregate_and_compile_expression = fun program exp -> let build_contract : Compiler.compiled_expression -> Michelson.michelson result = fun compiled -> - let%bind ((Ex_ty _param_ty),(Ex_ty _storage_ty)) = Self_michelson.fetch_lambda_parameters compiled.expr_ty in + let%bind ((Ex_ty _param_ty),(Ex_ty _storage_ty)) = Self_michelson.fetch_contract_inputs compiled.expr_ty in let%bind param_michelson = - Trace.trace_tzresult_lwt (simple_error "Could not unparse contract lambda's parameter") @@ + Trace.trace_tzresult_lwt (simple_error "Invalid contract: Could not unparse parameter") @@ Proto_alpha_utils.Memory_proto_alpha.unparse_ty_michelson _param_ty in let%bind storage_michelson = - Trace.trace_tzresult_lwt (simple_error "Could not unparse contract lambda's storage") @@ + Trace.trace_tzresult_lwt (simple_error "Invalid contract: Could not unparse storage") @@ Proto_alpha_utils.Memory_proto_alpha.unparse_ty_michelson _storage_ty in let contract = Michelson.contract param_michelson storage_michelson compiled.expr in let%bind () = - Trace.trace_tzresult_lwt (simple_error "Invalid contract") @@ + Trace.trace_tzresult_lwt (simple_error "Invalid contract: Contract did not typecheck") @@ Proto_alpha_utils.Memory_proto_alpha.typecheck_contract contract in ok contract diff --git a/src/passes/9-self_michelson/helpers.ml b/src/passes/9-self_michelson/helpers.ml index feca5a151..f7421546c 100644 --- a/src/passes/9-self_michelson/helpers.ml +++ b/src/passes/9-self_michelson/helpers.ml @@ -19,9 +19,8 @@ let rec map_expression : mapper -> michelson -> michelson result = fun f e -> | x -> ok x open Memory_proto_alpha.Protocol.Script_ir_translator -(* fetches lambda first and second parameter (parameter,storage) *) -let fetch_lambda_parameters : ex_ty -> (ex_ty * ex_ty) result = - let error () = simple_fail "failed to fetch lambda parameters" in +let fetch_contract_inputs : ex_ty -> (ex_ty * ex_ty) result = + let error () = simple_fail "Invalid contract: Failed to fetch parameter and storage" in function | Ex_ty (Lambda_t (in_ty, _, _)) -> ( match in_ty with