Source file script_tc_errors_registration.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
open Alpha_context
open Script
open Script_tc_errors
let stack_ty_enc = Data_encoding.list Script.expr_encoding
let type_map_enc =
let open Data_encoding in
list
(conv
(fun (loc, (bef, aft)) -> (loc, bef, aft))
(fun (loc, bef, aft) -> (loc, (bef, aft)))
(obj3
(req "location" Script.location_encoding)
(req "stack_before" stack_ty_enc)
(req "stack_after" stack_ty_enc)))
let () =
let open Data_encoding in
let located enc =
merge_objs (obj1 (req "location" Script.location_encoding)) enc
in
let arity_enc = int8 in
let namespace_enc =
def
"primitiveNamespace"
~title:"Primitive namespace"
~description:
"One of the five possible namespaces of primitive (data constructor, \
type name, instruction, keyword, or constant hash)."
@@ string_enum
[
("type", Michelson_v1_primitives.Type_namespace);
("constant", Constant_namespace);
("instruction", Instr_namespace);
("keyword", Keyword_namespace);
("constant_hash", Constant_hash_namespace);
]
in
let kind_enc =
def
"expressionKind"
~title:"Expression kind"
~description:
"One of the four possible kinds of expression (integer, string, \
primitive application or sequence)."
@@ string_enum
[
("integer", Int_kind);
("string", String_kind);
("bytes", Bytes_kind);
("primitiveApplication", Prim_kind);
("sequence", Seq_kind);
]
in
let context_desc_enc =
let open Data_encoding in
def "michelson_v1.context_desc"
@@ string_enum [("Lambda", Lambda); ("View", View)]
in
register_error_kind
`Permanent
~id:"michelson_v1.invalid_arity"
~title:"Invalid arity"
~description:
"In a script or data expression, a primitive was applied to an \
unsupported number of arguments."
(located
(obj3
(req "primitive_name" Script.prim_encoding)
(req "expected_arity" arity_enc)
(req "wrong_arity" arity_enc)))
(function
| Invalid_arity (loc, name, exp, got) -> Some (loc, (name, exp, got))
| _ -> None)
(fun (loc, (name, exp, got)) -> Invalid_arity (loc, name, exp, got)) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_seq_arity"
~title:"Invalid sequence arity"
~description:
"In a script or data expression, a sequence was used with a number of \
elements too small."
(located
(obj2
(req "minimal_expected_arity" arity_enc)
(req "wrong_arity" arity_enc)))
(function
| Invalid_seq_arity (loc, exp, got) -> Some (loc, (exp, got)) | _ -> None)
(fun (loc, (exp, got)) -> Invalid_seq_arity (loc, exp, got)) ;
register_error_kind
`Permanent
~id:"michelson_v1.missing_script_field"
~title:"Script is missing a field (parse error)"
~description:"When parsing script, a field was expected, but not provided"
(obj1 (req "prim" prim_encoding))
(function Missing_field prim -> Some prim | _ -> None)
(fun prim -> Missing_field prim) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_primitive"
~title:"Invalid primitive"
~description:"In a script or data expression, a primitive was unknown."
(located
(obj2
(dft "expected_primitive_names" (list prim_encoding) [])
(req "wrong_primitive_name" prim_encoding)))
(function
| Invalid_primitive (loc, exp, got) -> Some (loc, (exp, got)) | _ -> None)
(fun (loc, (exp, got)) -> Invalid_primitive (loc, exp, got)) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_expression_kind"
~title:"Invalid expression kind"
~description:
"In a script or data expression, an expression was of the wrong kind \
(for instance a string where only a primitive applications can appear)."
(located
(obj2 (req "expected_kinds" (list kind_enc)) (req "wrong_kind" kind_enc)))
(function
| Invalid_kind (loc, exp, got) -> Some (loc, (exp, got)) | _ -> None)
(fun (loc, (exp, got)) -> Invalid_kind (loc, exp, got)) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_primitive_namespace"
~title:"Invalid primitive namespace"
~description:
"In a script or data expression, a primitive was of the wrong namespace."
(located
(obj3
(req "primitive_name" prim_encoding)
(req "expected_namespace" namespace_enc)
(req "wrong_namespace" namespace_enc)))
(function
| Invalid_namespace (loc, name, exp, got) -> Some (loc, (name, exp, got))
| _ -> None)
(fun (loc, (name, exp, got)) -> Invalid_namespace (loc, name, exp, got)) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_never_expr"
~title:"Invalid expression for type never"
~description:
"In a script or data expression, an expression was provided but a value \
of type never was expected. No expression can have type never."
(located unit)
(function Invalid_never_expr loc -> Some (loc, ()) | _ -> None)
(fun (loc, ()) -> Invalid_never_expr loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.duplicate_script_field"
~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:"michelson_v1.unexpected_lazy_storage"
~title:"Lazy storage in unauthorized position (type error)"
~description:
"When parsing script, a big_map or sapling_state type was found in a \
position where it could end up stored inside a big_map, which is \
forbidden for now."
(obj1 (req "loc" location_encoding))
(function Unexpected_lazy_storage loc -> Some loc | _ -> None)
(fun loc -> Unexpected_lazy_storage loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.unexpected_operation"
~title:"Operation in unauthorized position (type error)"
~description:
"When parsing script, an operation type was found in the storage or \
parameter field."
(obj1 (req "loc" location_encoding))
(function Unexpected_operation loc -> Some loc | _ -> None)
(fun loc -> Unexpected_operation loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.no_such_entrypoint"
~title:"No such entrypoint (type error)"
~description:"An entrypoint was not found when calling a contract."
(obj1 (req "entrypoint" Entrypoint.simple_encoding))
(function No_such_entrypoint entrypoint -> Some entrypoint | _ -> None)
(fun entrypoint -> No_such_entrypoint entrypoint) ;
register_error_kind
`Permanent
~id:"michelson_v1.unreachable_entrypoint"
~title:"Unreachable entrypoint (type error)"
~description:"An entrypoint in the contract is not reachable."
(obj1 (req "path" (list prim_encoding)))
(function Unreachable_entrypoint path -> Some path | _ -> None)
(fun path -> Unreachable_entrypoint path) ;
register_error_kind
`Permanent
~id:"michelson_v1.tx_rollup_bad_deposit_parameter"
~title:"Bad deposit parameter"
~description:
"The parameter to the deposit entrypoint of a transaction rollup should \
be a pair of a ticket and the address of a recipient transaction \
rollup."
(located (obj1 (req "parameter" Script.expr_encoding)))
(function
| Tx_rollup_bad_deposit_parameter (loc, expr) -> Some (loc, expr)
| _ -> None)
(fun (loc, expr) -> Tx_rollup_bad_deposit_parameter (loc, expr)) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_tx_rollup_ticket_amount"
~title:"Invalid ticket amount"
~description:
"Ticket amount to be deposited in a transaction rollup should be \
strictly positive and fit in a signed 64-bit integer"
(obj1 (req "requested_value" Data_encoding.z))
(function Tx_rollup_invalid_ticket_amount z -> Some z | _ -> None)
(fun z -> Tx_rollup_invalid_ticket_amount z) ;
register_error_kind
`Permanent
~id:"michelson_v1.forbidden_zero_amount_ticket"
~title:"Zero ticket amount is not allowed"
~description:
"It is not allowed to use a zero amount ticket in this operation."
Data_encoding.empty
(function Forbidden_zero_ticket_quantity -> Some () | _ -> None)
(fun () -> Forbidden_zero_ticket_quantity) ;
register_error_kind
`Permanent
~id:"michelson_v1.sc_rollup_disabled"
~title:"Sc rollup are disabled"
~description:"Cannot use smart rollup features as they are disabled."
(obj1 (req "location" Script.location_encoding))
(function Sc_rollup_disabled loc -> Some loc | _ -> None)
(fun loc -> Sc_rollup_disabled loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.duplicate_entrypoint"
~title:"Duplicate entrypoint (type error)"
~description:"Two entrypoints have the same name."
(obj1 (req "path" Entrypoint.simple_encoding))
(function Duplicate_entrypoint entrypoint -> Some entrypoint | _ -> None)
(fun entrypoint -> Duplicate_entrypoint entrypoint) ;
register_error_kind
`Permanent
~id:"michelson_v1.unexpected_contract"
~title:"Contract in unauthorized position (type error)"
~description:
"When parsing script, a contract type was found in the storage or \
parameter field."
(obj1 (req "loc" location_encoding))
(function Unexpected_contract loc -> Some loc | _ -> None)
(fun loc -> Unexpected_contract loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.unordered_map_literal"
~title:"Invalid map key order"
~description:"Map keys must be in strictly increasing order"
(obj2
(req "location" Script.location_encoding)
(req "item" Script.expr_encoding))
(function Unordered_map_keys (loc, expr) -> Some (loc, expr) | _ -> None)
(fun (loc, expr) -> Unordered_map_keys (loc, expr)) ;
register_error_kind
`Permanent
~id:"michelson_v1.duplicate_map_keys"
~title:"Duplicate map keys"
~description:"Map literals cannot contain duplicated keys"
(obj2
(req "location" Script.location_encoding)
(req "item" Script.expr_encoding))
(function Duplicate_map_keys (loc, expr) -> Some (loc, expr) | _ -> None)
(fun (loc, expr) -> Duplicate_map_keys (loc, expr)) ;
register_error_kind
`Permanent
~id:"michelson_v1.unordered_set_literal"
~title:"Invalid set value order"
~description:"Set values must be in strictly increasing order"
(obj2
(req "location" Script.location_encoding)
(req "value" Script.expr_encoding))
(function
| Unordered_set_values (loc, expr) -> Some (loc, expr) | _ -> None)
(fun (loc, expr) -> Unordered_set_values (loc, expr)) ;
register_error_kind
`Permanent
~id:"michelson_v1.duplicate_set_values_in_literal"
~title:"Sets literals cannot contain duplicate elements"
~description:
"Set literals cannot contain duplicate elements, but a duplicate was \
found while parsing."
(obj2
(req "location" Script.location_encoding)
(req "value" Script.expr_encoding))
(function
| Duplicate_set_values (loc, expr) -> Some (loc, expr) | _ -> None)
(fun (loc, expr) -> Duplicate_set_values (loc, expr)) ;
register_error_kind
`Permanent
~id:"michelson_v1.fail_not_in_tail_position"
~title:"FAIL not in tail position"
~description:"There is non trivial garbage code after a FAIL instruction."
(located empty)
(function Fail_not_in_tail_position loc -> Some (loc, ()) | _ -> None)
(fun (loc, ()) -> Fail_not_in_tail_position loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.undefined_binop"
~title:"Undefined binop"
~description:
"A binary operation is called on operands of types over which it is not \
defined."
(located
(obj3
(req "operator_name" prim_encoding)
(req "wrong_left_operand_type" Script.expr_encoding)
(req "wrong_right_operand_type" Script.expr_encoding)))
(function
| Undefined_binop (loc, n, tyl, tyr) -> Some (loc, (n, tyl, tyr))
| _ -> None)
(fun (loc, (n, tyl, tyr)) -> Undefined_binop (loc, n, tyl, tyr)) ;
register_error_kind
`Permanent
~id:"michelson_v1.undefined_unop"
~title:"Undefined unop"
~description:
"A unary operation is called on an operand of type over which it is not \
defined."
(located
(obj2
(req "operator_name" prim_encoding)
(req "wrong_operand_type" Script.expr_encoding)))
(function Undefined_unop (loc, n, ty) -> Some (loc, (n, ty)) | _ -> None)
(fun (loc, (n, ty)) -> Undefined_unop (loc, n, ty)) ;
register_error_kind
`Permanent
~id:"michelson_v1.bad_return"
~title:"Bad return"
~description:"Unexpected stack at the end of a lambda or script."
(located
(obj2
(req "expected_return_type" Script.expr_encoding)
(req "wrong_stack_type" stack_ty_enc)))
(function Bad_return (loc, sty, ty) -> Some (loc, (ty, sty)) | _ -> None)
(fun (loc, (ty, sty)) -> Bad_return (loc, sty, ty)) ;
register_error_kind
`Permanent
~id:"michelson_v1.bad_stack"
~title:"Bad stack"
~description:"The stack has an unexpected length or contents."
(located
(obj3
(req "primitive_name" prim_encoding)
(req "relevant_stack_portion" int16)
(req "wrong_stack_type" stack_ty_enc)))
(function
| Bad_stack (loc, name, s, sty) -> Some (loc, (name, s, sty)) | _ -> None)
(fun (loc, (name, s, sty)) -> Bad_stack (loc, name, s, sty)) ;
register_error_kind
`Permanent
~id:"michelson_v1.unexpected_annotation"
~title:"An annotation was encountered where no annotation is expected"
~description:"A node in the syntax tree was improperly annotated"
(located empty)
(function Unexpected_annotation loc -> Some (loc, ()) | _ -> None)
(fun (loc, ()) -> Unexpected_annotation loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.ungrouped_annotations"
~title:"Annotations of the same kind were found spread apart"
~description:"Annotations of the same kind must be grouped"
(located empty)
(function Ungrouped_annotations loc -> Some (loc, ()) | _ -> None)
(fun (loc, ()) -> Ungrouped_annotations loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.unmatched_branches"
~title:"Unmatched branches"
~description:
"At the join point at the end of two code branches the stacks have \
inconsistent lengths or contents."
(located
(obj2
(req "first_stack_type" stack_ty_enc)
(req "other_stack_type" stack_ty_enc)))
(function
| Unmatched_branches (loc, stya, styb) -> Some (loc, (stya, styb))
| _ -> None)
(fun (loc, (stya, styb)) -> Unmatched_branches (loc, stya, styb)) ;
register_error_kind
`Permanent
~id:"michelson_v1.bad_stack_item"
~title:"Bad stack item"
~description:
"The type of a stack item is unexpected (this error is always \
accompanied by a more precise one)."
(obj1 (req "item_level" int16))
(function Bad_stack_item n -> Some n | _ -> None)
(fun n -> Bad_stack_item n) ;
register_error_kind
`Permanent
~id:"michelson_v1.forbidden_instr_in_context"
~title:"Forbidden instruction in context"
~description:
"An instruction was encountered in a context where it is forbidden."
(located
(obj2
(req "context" context_desc_enc)
(req "forbidden_instruction" prim_encoding)))
(function
| Forbidden_instr_in_context (loc, ctxt, prim) -> Some (loc, (ctxt, prim))
| _ -> None)
(fun (loc, (ctxt, prim)) -> Forbidden_instr_in_context (loc, ctxt, prim)) ;
register_error_kind
`Permanent
~id:"michelson_v1.inconsistent_stack_lengths"
~title:"Inconsistent stack lengths"
~description:
"A stack was of an unexpected length (this error is always in the \
context of a located error)."
empty
(function Bad_stack_length -> Some () | _ -> None)
(fun () -> Bad_stack_length) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_constant"
~title:"Invalid constant"
~description:"A data expression was invalid for its expected type."
(located
(obj2
(req "expected_type" Script.expr_encoding)
(req "wrong_expression" Script.expr_encoding)))
(function
| Invalid_constant (loc, expr, ty) -> Some (loc, (ty, expr)) | _ -> None)
(fun (loc, (ty, expr)) -> Invalid_constant (loc, expr, ty)) ;
register_error_kind
`Permanent
~id:"michelson_v1.view_name_too_long"
~title:"View name too long (type error)"
~description:"A view name exceeds the maximum length of 31 characters."
(obj1 (req "name" (string Plain)))
(function View_name_too_long name -> Some name | _ -> None)
(fun name -> View_name_too_long name) ;
register_error_kind
`Permanent
~id:"michelson_v1.duplicated_view_name"
~title:"Duplicated view name"
~description:"The name of view in toplevel should be unique."
(obj1 (req "location" Script.location_encoding))
(function Duplicated_view_name loc -> Some loc | _ -> None)
(fun loc -> Duplicated_view_name loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_syntactic_constant"
~title:"Invalid constant (parse error)"
~description:"A compile-time constant was invalid for its expected form."
(located
(obj2
(req "expected_form" (string Plain))
(req "wrong_expression" Script.expr_encoding)))
(function
| Invalid_syntactic_constant (loc, expr, expected) ->
Some (loc, (expected, expr))
| _ -> None)
(fun (loc, (expected, expr)) ->
Invalid_syntactic_constant (loc, expr, expected)) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_contract"
~title:"Invalid contract"
~description:
"A script or data expression references a contract that does not exist \
or assumes a wrong type for an existing contract."
(located (obj1 (req "contract" Contract.encoding)))
(function Invalid_contract (loc, c) -> Some (loc, c) | _ -> None)
(fun (loc, c) -> Invalid_contract (loc, c)) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_big_map"
~title:"Invalid big_map"
~description:
"A script or data expression references a big_map that does not exist or \
assumes a wrong type for an existing big_map."
(located (obj1 (req "big_map" Big_map.Id.encoding)))
(function Invalid_big_map (loc, c) -> Some (loc, c) | _ -> None)
(fun (loc, c) -> Invalid_big_map (loc, c)) ;
register_error_kind
`Permanent
~id:"michelson_v1.comparable_type_expected"
~title:"Comparable type expected"
~description:
"A non comparable type was used in a place where only comparable types \
are accepted."
(located (obj1 (req "wrong_type" Script.expr_encoding)))
(function
| Comparable_type_expected (loc, ty) -> Some (loc, ty) | _ -> None)
(fun (loc, ty) -> Comparable_type_expected (loc, ty)) ;
register_error_kind
`Permanent
~id:"michelson_v1.inconsistent_type_sizes"
~title:"Inconsistent type sizes"
~description:
"Two types were expected to be equal but they have different sizes."
(obj2 (req "first_type_size" int31) (req "other_type_size" int31))
(function
| Inconsistent_type_sizes (tya, tyb) -> Some (tya, tyb) | _ -> None)
(fun (tya, tyb) -> Inconsistent_type_sizes (tya, tyb)) ;
register_error_kind
`Permanent
~id:"michelson_v1.inconsistent_types"
~title:"Inconsistent types"
~description:
"This is the basic type clash error, that appears in several places \
where the equality of two types have to be proven, it is always \
accompanied with another error that provides more context."
(obj3
(req "loc" Script.location_encoding)
(req "first_type" Script.expr_encoding)
(req "other_type" Script.expr_encoding))
(function
| Inconsistent_types (loc, tya, tyb) -> Some (loc, tya, tyb) | _ -> None)
(fun (loc, tya, tyb) -> Inconsistent_types (loc, tya, tyb)) ;
register_error_kind
`Permanent
~id:"michelson_v1.unexpected_implicit_account_parameters_type"
~title:"Unexpected implicit account parameters type"
~description:
"An implicit account can only accept either a unit or a ticket value as \
a call parameter."
(obj2
(req "loc" Script.location_encoding)
(req "type" Script.expr_encoding))
(function
| Unexpected_implicit_account_parameters_type (loc, ty) -> Some (loc, ty)
| _ -> None)
(fun (loc, ty) -> Unexpected_implicit_account_parameters_type (loc, ty)) ;
register_error_kind
`Permanent
~id:"michelson_v1.inconsistent_memo_sizes"
~title:"Inconsistent memo sizes"
~description:"Memo sizes of two sapling states or transactions do not match"
(obj2
(req "first_memo_size" Sapling.Memo_size.encoding)
(req "other_memo_size" Sapling.Memo_size.encoding))
(function
| Inconsistent_memo_sizes (msa, msb) -> Some (msa, msb) | _ -> None)
(fun (msa, msb) -> Inconsistent_memo_sizes (msa, msb)) ;
register_error_kind
`Permanent
~id:"michelson_v1.bad_view_name"
~title:"Bad view name"
~description:"In a view declaration, the view name must be a string"
(obj1 (req "loc" Script.location_encoding))
(function Bad_view_name loc -> Some loc | _ -> None)
(fun loc -> Bad_view_name loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.ill_typed_view"
~title:"Ill typed view"
~description:"The return of a view block did not match the expected type"
(obj3
(req "loc" Script.location_encoding)
(req "resulted_view_stack" stack_ty_enc)
(req "expected_view_stack" stack_ty_enc))
(function
| Ill_typed_view {loc; actual; expected} -> Some (loc, actual, expected)
| _ -> None)
(fun (loc, actual, expected) -> Ill_typed_view {loc; actual; expected}) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_map_body"
~title:"Invalid map body"
~description:"The body of a map block did not match the expected type"
(obj2 (req "loc" Script.location_encoding) (req "body_type" stack_ty_enc))
(function Invalid_map_body (loc, stack) -> Some (loc, stack) | _ -> None)
(fun (loc, stack) -> Invalid_map_body (loc, stack)) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_map_block_fail"
~title:"FAIL instruction occurred as body of map block"
~description:
"FAIL cannot be the only instruction in the body. The proper type of the \
return list cannot be inferred."
(obj1 (req "loc" Script.location_encoding))
(function Invalid_map_block_fail loc -> Some loc | _ -> None)
(fun loc -> Invalid_map_block_fail loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.invalid_iter_body"
~title:"ITER body returned wrong stack type"
~description:
"The body of an ITER instruction must result in the same stack type as \
before the ITER."
(obj3
(req "loc" Script.location_encoding)
(req "bef_stack" stack_ty_enc)
(req "aft_stack" stack_ty_enc))
(function
| Invalid_iter_body (loc, bef, aft) -> Some (loc, bef, aft) | _ -> None)
(fun (loc, bef, aft) -> Invalid_iter_body (loc, bef, aft)) ;
register_error_kind
`Permanent
~id:"michelson_v1.type_too_large"
~title:"Stack item type too large"
~description:"An instruction generated a type larger than the limit."
(obj2 (req "loc" Script.location_encoding) (req "maximum_type_size" uint16))
(function Type_too_large (loc, maxts) -> Some (loc, maxts) | _ -> None)
(fun (loc, maxts) -> Type_too_large (loc, maxts)) ;
register_error_kind
`Permanent
~id:"michelson_v1.bad_pair_argument"
~title:"0 or 1 passed to PAIR"
~description:"PAIR expects an argument of at least 2"
(obj1 (req "loc" Script.location_encoding))
(function Pair_bad_argument loc -> Some loc | _ -> None)
(fun loc -> Pair_bad_argument loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.bad_unpair_argument"
~title:"0 or 1 passed to UNPAIR"
~description:"UNPAIR expects an argument of at least 2"
(obj1 (req "loc" Script.location_encoding))
(function Unpair_bad_argument loc -> Some loc | _ -> None)
(fun loc -> Unpair_bad_argument loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.bad_dupn_argument"
~title:"0 passed to DUP n"
~description:"DUP expects an argument of at least 1 (passed 0)"
(obj1 (req "loc" Script.location_encoding))
(function Dup_n_bad_argument loc -> Some loc | _ -> None)
(fun loc -> Dup_n_bad_argument loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.bad_dupn_stack"
~title:"Stack too short when typing DUP n"
~description:"Stack present when typing DUP n was too short"
(obj1 (req "loc" Script.location_encoding))
(function Dup_n_bad_stack x -> Some x | _ -> None)
(fun x -> Dup_n_bad_stack x) ;
register_error_kind
`Permanent
~id:"michelson_v1.ill_typed_data"
~title:"Ill typed data"
~description:
"The toplevel error thrown when trying to typecheck a data expression \
against a given type (always followed by more precise errors)."
(obj3
(opt "identifier" (string Plain))
(req "expected_type" Script.expr_encoding)
(req "ill_typed_expression" Script.expr_encoding))
(function
| Ill_typed_data (name, expr, ty) -> Some (name, ty, expr) | _ -> None)
(fun (name, ty, expr) -> Ill_typed_data (name, expr, ty)) ;
register_error_kind
`Permanent
~id:"michelson_v1.ill_formed_type"
~title:"Ill formed type"
~description:
"The toplevel error thrown when trying to parse a type expression \
(always followed by more precise errors)."
(obj3
(opt "identifier" (string Plain))
(req "ill_formed_expression" Script.expr_encoding)
(req "location" Script.location_encoding))
(function
| Ill_formed_type (name, expr, loc) -> Some (name, expr, loc) | _ -> None)
(fun (name, expr, loc) -> Ill_formed_type (name, expr, loc)) ;
register_error_kind
`Permanent
~id:"michelson_v1.ill_typed_contract"
~title:"Ill typed contract"
~description:
"The toplevel error thrown when trying to typecheck a contract code \
against given input, output and storage types (always followed by more \
precise errors)."
(obj2
(req "ill_typed_code" Script.expr_encoding)
(req "type_map" type_map_enc))
(function
| Ill_typed_contract (expr, type_map) -> Some (expr, type_map) | _ -> None)
(fun (expr, type_map) -> Ill_typed_contract (expr, type_map)) ;
register_error_kind
`Permanent
~id:"michelson_v1.deprecated_instruction"
~title:"Script is using a deprecated instruction"
~description:
"A deprecated instruction usage is disallowed in newly created contracts"
(obj1 (req "prim" prim_encoding))
(function Deprecated_instruction prim -> Some prim | _ -> None)
(fun prim -> Deprecated_instruction prim) ;
register_error_kind
`Temporary
~id:"michelson_v1.typechecking_too_many_recursive_calls"
~title:"Too many recursive calls during typechecking"
~description:"Too many recursive calls were needed for typechecking"
Data_encoding.empty
(function Typechecking_too_many_recursive_calls -> Some () | _ -> None)
(fun () -> Typechecking_too_many_recursive_calls) ;
register_error_kind
`Temporary
~id:"michelson_v1.unparsing_stack_overflow"
~title:"Too many recursive calls during unparsing"
~description:"Too many recursive calls were needed for unparsing"
Data_encoding.empty
(function Unparsing_too_many_recursive_calls -> Some () | _ -> None)
(fun () -> Unparsing_too_many_recursive_calls) ;
register_error_kind
`Permanent
~id:"michelson_v1.unexpected_forged_value"
~title:"Unexpected forged value"
~description:
"A forged value was encountered but disallowed for that position."
(obj1 (req "location" Script.location_encoding))
(function Unexpected_forged_value loc -> Some loc | _ -> None)
(fun loc -> Unexpected_forged_value loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.unexpected_ticket"
~title:"Ticket in unauthorized position (type error)"
~description:"A ticket type has been found"
(obj1 (req "loc" location_encoding))
(function Unexpected_ticket loc -> Some loc | _ -> None)
(fun loc -> Unexpected_ticket loc) ;
register_error_kind
`Permanent
~id:"michelson_v1.non_dupable_type"
~title:"Non-dupable type duplication attempt"
~description:"DUP was used on a non-dupable type (e.g. tickets)."
(obj2 (req "loc" location_encoding) (req "type" Script.expr_encoding))
(function Non_dupable_type (loc, ty) -> Some (loc, ty) | _ -> None)
(fun (loc, ty) -> Non_dupable_type (loc, ty)) ;
register_error_kind
`Permanent
~id:"michelson_v1.unexpected_ticket_owner"
~title:"Unexpected ticket owner"
~description:"Ticket can only be created by a smart contract"
(obj1 (req "ticketer" Destination.encoding))
(function Unexpected_ticket_owner t -> Some t | _ -> None)
(fun t -> Unexpected_ticket_owner t)