List.fold_left : wrong argument order
Shame. I have only tested cases where args have the same types.
[@@@SCaml iml_optimization=false]
open SCaml
let [@entry] main () () =
[],
assert ( List.fold_left (fun acc x -> acc || x = Int 0) false [ Int 1; Int 2; Int 3 ] = false )
Ill typed contract:
01: parameter unit ;
02: storage unit ;
03: code { { /* top defs */ } ;
04: { /* entry point init */ DUP ; CDR ; DIP { CAR } } ;
05: { /* entry point code */
06: { /* = */
07: PUSH bool False ;
08: { /* List.fold_left */
09: PUSH (list int) { 1 ; 2 ; 3 } ;
10: PUSH bool False ;
11: PUSH (lambda bool (lambda int bool))
12: { LAMBDA
13: (pair bool int)
14: bool
15: { { /* fvar __acc_158 */ DUP ; DIP { CAR } ; CDR } ;
16: { /* || */
17: { /* = */ PUSH int 0 ; { /* var __x_159 */ DIG 1 ; DUP ; DUG 2 } ; COMPARE ; EQ } ;
18: { /* var __acc_158 */ DIG 2 ; DUP ; DUG 3 } ;
19: OR } ;
20: DIP { DROP 2 }
21: /* lambda clean up */ } ;
22: { /* partial app __acc_158 */ { /* var __acc_158 */ DIG 1 ; DUP ; DUG 2 } ; APPLY } ;
23: DIP { DROP }
24: /* lambda clean up */ } ;
25: SWAP ;
26: DIP { SWAP } ;
27: SWAP ;
28: ITER { DIP { DIP { DUP } ; SWAP } ; EXEC ; SWAP ; EXEC } ;
29: DIP { DROP } } ;
30: COMPARE ;
31: EQ } ;
32: ASSERT ;
33: UNIT ;
34: NIL operation ;
35: PAIR } ;
36: DIP { DROP 2 }
37: /* final clean up */ } ;
38:
39:
At line 28 characters 49 to 53, wrong stack type for instruction EXEC:
[ int @elt : lambda bool (lambda int bool) : ... ].
Bad stack item 1.
Type int is not compatible with type bool.
Fatal error:
ill-typed script