Michelson: export and printing for Duplicate_field error

This commit is contained in:
Milo Davis 2018-01-27 00:07:45 -05:00 committed by Benjamin Canou
parent 695b23bd92
commit d1b4230962
3 changed files with 18 additions and 0 deletions

View File

@ -64,6 +64,7 @@ let collect_error_locations errs =
| Invalid_namespace (loc, _, _, _)
| Invalid_primitive (loc, _, _)
| Invalid_kind (loc, _, _)
| Duplicate_field (loc, _)
| Fail_not_in_tail_position loc
| Undefined_binop (loc, _, _, _)
| Undefined_unop (loc, _, _)
@ -160,6 +161,11 @@ let report_errors ~details ~show_source ?parsed ppf errs =
Format.fprintf ppf "@[<v 0>Missing contract field: %s@]"
(Michelson_v1_primitives.string_of_prim prim) ;
print_trace locations rest
| Duplicate_field (loc, prim) :: rest ->
Format.fprintf ppf "@[<v 0>%aduplicate contract field: %s@]"
print_loc loc
(Michelson_v1_primitives.string_of_prim prim) ;
print_trace locations rest
| Runtime_contract_error (contract, expr) :: rest ->
let parsed =
match parsed with

View File

@ -2214,6 +2214,17 @@ let () =
(obj1 (req "prim" prim_encoding))
(function Missing_field prim -> Some prim | _ -> None)
(fun prim -> Missing_field prim) ;
register_error_kind
`Permanent
~id:"duplicateScriptField"
~title:"Script has a duplicated field (parse error)"
~description:
"When parsing script, a field was found more than once"
(obj2
(req "loc" location_encoding)
(req "prim" prim_encoding))
(function Duplicate_field (loc, prim) -> Some (loc, prim) | _ -> None)
(fun (loc, prim) -> Duplicate_field (loc, prim)) ;
register_error_kind
`Permanent
~id:"invalidPrimitiveTypeError"

View File

@ -30,6 +30,7 @@ type error += Invalid_primitive of Script.location * Script.prim list * Script.p
type error += Invalid_kind of Script.location * kind list * kind
type error += Missing_field of Script.prim
type error += Type_too_large : Script.location * int * int -> error
type error += Duplicate_field of Script.location * Script.prim
(* Instruction typing errors *)
type error += Fail_not_in_tail_position of Script.location