From 861bf10583db9ca455f0ed11d12eb4bc876ed42b Mon Sep 17 00:00:00 2001 From: Pierrick Couderc Date: Thu, 13 Nov 2025 14:21:06 +0100 Subject: [PATCH 1/2] Proto/T: improve the trace for unpackable types --- .../lib_client/michelson_v1_error_reporter.ml | 8 ++++++++ .../lib_protocol/script_ir_translator.ml | 2 +- .../lib_protocol/script_tc_errors.ml | 2 ++ .../lib_protocol/script_tc_errors_registration.ml | 11 +++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/proto_024_PsD5wVTJ/lib_client/michelson_v1_error_reporter.ml b/src/proto_024_PsD5wVTJ/lib_client/michelson_v1_error_reporter.ml index 366a0169c7d5..a6bce438a98c 100644 --- a/src/proto_024_PsD5wVTJ/lib_client/michelson_v1_error_reporter.ml +++ b/src/proto_024_PsD5wVTJ/lib_client/michelson_v1_error_reporter.ml @@ -426,6 +426,14 @@ let report_errors ~details ~show_source loc ; if rest <> [] then Format.fprintf ppf "@," ; print_trace locations rest + | Environment.Ecoproto_error (Unpackable_type loc) :: rest -> + Format.fprintf + ppf + "%aValue has a type that cannot be packed" + print_loc + loc ; + if rest <> [] then Format.fprintf ppf "@," ; + print_trace locations rest | Environment.Ecoproto_error (Runtime_contract_error contract) :: rest -> Format.fprintf ppf diff --git a/src/proto_024_PsD5wVTJ/lib_protocol/script_ir_translator.ml b/src/proto_024_PsD5wVTJ/lib_protocol/script_ir_translator.ml index b91d2d871142..ac443596f3e9 100644 --- a/src/proto_024_PsD5wVTJ/lib_protocol/script_ir_translator.ml +++ b/src/proto_024_PsD5wVTJ/lib_protocol/script_ir_translator.ml @@ -1114,7 +1114,7 @@ let check_packable ~allow_contract loc root = | Chest_key_t -> return_unit | Chest_t -> return_unit in - check root + record_trace (Unpackable_type loc) (check root) type toplevel = { code_field : Script.node; diff --git a/src/proto_024_PsD5wVTJ/lib_protocol/script_tc_errors.ml b/src/proto_024_PsD5wVTJ/lib_protocol/script_tc_errors.ml index d3e8855e3807..1b542fa1ba7a 100644 --- a/src/proto_024_PsD5wVTJ/lib_protocol/script_tc_errors.ml +++ b/src/proto_024_PsD5wVTJ/lib_protocol/script_tc_errors.ml @@ -62,6 +62,8 @@ type error += Unexpected_operation of Script.location type error += Unexpected_contract of Script.location +type error += Unpackable_type of Script.location + type error += No_such_entrypoint of Entrypoint.t type error += Duplicate_entrypoint of Entrypoint.t diff --git a/src/proto_024_PsD5wVTJ/lib_protocol/script_tc_errors_registration.ml b/src/proto_024_PsD5wVTJ/lib_protocol/script_tc_errors_registration.ml index a24e2c6545bf..9870e53b79a1 100644 --- a/src/proto_024_PsD5wVTJ/lib_protocol/script_tc_errors_registration.ml +++ b/src/proto_024_PsD5wVTJ/lib_protocol/script_tc_errors_registration.ml @@ -211,6 +211,17 @@ let () = (obj1 (req "loc" location_encoding)) (function Unexpected_operation loc -> Some loc | _ -> None) (fun loc -> Unexpected_operation loc) ; + (* Unpackable type *) + register_error_kind + `Permanent + ~id:"michelson_v1.unpackable_type" + ~title:"Type cannot be packed (type error)" + ~description: + "When parsing script, a value was given to a primitive that expects a \ + packable type." + (obj1 (req "loc" location_encoding)) + (function Unpackable_type loc -> Some loc | _ -> None) + (fun loc -> Unpackable_type loc) ; (* No such entrypoint *) register_error_kind `Permanent -- GitLab From 88857ae6322c72110e5f9f137a0eb2264c4c3fe5 Mon Sep 17 00:00:00 2001 From: Pierrick Couderc Date: Thu, 13 Nov 2025 14:30:00 +0100 Subject: [PATCH 2/2] Proto/T: Changelog: add an entry for new error messages for unpackable values --- docs/protocols/024_t024.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/protocols/024_t024.rst b/docs/protocols/024_t024.rst index 813ce48fcdb7..7bec9fa44b99 100644 --- a/docs/protocols/024_t024.rst +++ b/docs/protocols/024_t024.rst @@ -46,6 +46,9 @@ Michelson the address has already been indexed through ``INDEX_ADDRESS``; it returns ``None`` otherwise. (MR :gl:`!18866`) +- Improved error message when using non packable values with ``PACK``, + ``FAILWITH`` and ``EMIT``, and in parameters of partially applied + ``LAMBDA``. (MR :gl:`!19889`) Gas improvements ---------------- -- GitLab