Skip to content

Instantly share code, notes, and snippets.

@yoshihiro503
Created January 10, 2020 09:16
Show Gist options
  • Save yoshihiro503/9372153b94b8c133dc81314182cc85c4 to your computer and use it in GitHub Desktop.
Save yoshihiro503/9372153b94b8c133dc81314182cc85c4 to your computer and use it in GitHub Desktop.
An example scaml code to fail `tezos-client typecheck script`
open SCaml
type parameter = nat * unit contract * unit
type storage = nat
let main (param: parameter) (storage: storage) =
let (counter, contr, sigs) = param in
(* let counter = counter in *) (* If this line is available then the typecheck will be passed. *)
if counter <> Nat 1 then failwith "0" else
let op = Operation.transfer_tokens () (Tz 1.) contr in
([op], counter)
@yoshihiro503
Copy link
Author

The iml by scaml --dump-iml typeerror.ml.

(fun global_param_1163 ->
   (fun storage_1162 ->
      (let __v_1175
         = (global_param_1163 </* = __x_1170 *//* = __param_1184 *//* = param_1153 *//* = __v_1185 *//* = __param_1164 */> : pair nat (pair (contract unit) unit))
       in
       (let __r_1176
          = (snd (__v_1175 : pair nat (pair (contract unit) unit)) : pair (contract unit) unit)
        in
        ((let __counter_1172
            = (fst (__v_1175 : pair nat (pair (contract unit) unit)) </* = counter_1155 *//* = __l_1177 */> : nat)
          in
          (fun __contr_1173 ->
             (fun __sigs_1174 ->
                (if (<> (__counter_1172 : nat) (1 : nat) : bool)
                 then (failwith ("0" : string) : pair (list operation) nat)
                 else (((Operation.transfer_tokens (() : unit) (1000000 : mutez) (__contr_1173 : contract unit) </* = __op_1168 *//* = op_1158 *//* = __v_1169 *//* = __x_1166 */> : operation) :: ([] : list operation) : list operation),
                       (__counter_1172 : nat) : pair (list operation) nat) : pair (list operation) nat) : lambda unit (pair (list operation) nat)) : lambda (contract unit) (lambda unit (pair (list operation) nat))) : lambda (contract unit) (lambda unit (pair (list operation) nat))) 
        (fst (__r_1176 : pair (contract unit) unit) </* = contr_1156 *//* = __l_1179 */> : contract unit) (snd (__r_1176 : pair (contract unit) unit) </* = sigs_1157 *//* = __r_1178 */> : unit) : pair (list operation) nat) : pair (list operation) nat) </* entry main_1152 */> : pair (list operation) nat) : lambda nat (pair (list operation) nat)) : lambda (pair nat (pair (contract unit) unit)) (lambda nat (pair (list operation) nat)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment