Merge branch 'typechecking-gas' into 'dev'
More more typechecking gas See merge request ligolang/ligo!484
This commit is contained in:
commit
cd4c8c9d29
@ -23,6 +23,9 @@ module Errors = struct
|
|||||||
let code = Format.asprintf "%a" Michelson.pp c in
|
let code = Format.asprintf "%a" Michelson.pp c in
|
||||||
"bad contract type\n"^code in
|
"bad contract type\n"^code in
|
||||||
error title_type_check_msg message
|
error title_type_check_msg message
|
||||||
|
let ran_out_of_gas () =
|
||||||
|
let message () = "Ran out of gas!" in
|
||||||
|
error title_type_check_msg message
|
||||||
let unknown () =
|
let unknown () =
|
||||||
let message () =
|
let message () =
|
||||||
"unknown error" in
|
"unknown error" in
|
||||||
@ -47,6 +50,7 @@ let build_contract : Compiler.compiled_expression -> Michelson.michelson result
|
|||||||
| Err_parameter -> fail @@ Errors.bad_parameter contract ()
|
| Err_parameter -> fail @@ Errors.bad_parameter contract ()
|
||||||
| Err_storage -> fail @@ Errors.bad_storage contract ()
|
| Err_storage -> fail @@ Errors.bad_storage contract ()
|
||||||
| Err_contract -> fail @@ Errors.bad_contract contract ()
|
| Err_contract -> fail @@ Errors.bad_contract contract ()
|
||||||
|
| Err_gas -> fail @@ Errors.ran_out_of_gas ()
|
||||||
| Err_unknown -> fail @@ Errors.unknown ()
|
| Err_unknown -> fail @@ Errors.unknown ()
|
||||||
|
|
||||||
type check_type = Check_parameter | Check_storage
|
type check_type = Check_parameter | Check_storage
|
||||||
|
@ -1107,16 +1107,17 @@ let unparse_ty_michelson ty =
|
|||||||
type typecheck_res =
|
type typecheck_res =
|
||||||
| Type_checked
|
| Type_checked
|
||||||
| Err_parameter | Err_storage | Err_contract
|
| Err_parameter | Err_storage | Err_contract
|
||||||
|
| Err_gas
|
||||||
| Err_unknown
|
| Err_unknown
|
||||||
|
|
||||||
let typecheck_contract contract =
|
let typecheck_contract contract =
|
||||||
let contract' = Tezos_micheline.Micheline.strip_locations contract in
|
let contract' = Tezos_micheline.Micheline.strip_locations contract in
|
||||||
let ctxt = Raw_context.set_gas_unlimited dummy_environment.tezos_context in
|
Script_ir_translator.typecheck_code dummy_environment.tezos_context contract' >>= fun x ->
|
||||||
Script_ir_translator.typecheck_code ctxt contract' >>= fun x ->
|
|
||||||
match x with
|
match x with
|
||||||
| Ok _res -> return Type_checked
|
| Ok _res -> return Type_checked
|
||||||
| Error (Script_tc_errors.Ill_formed_type (Some "parameter", _code, _)::_) -> return Err_parameter
|
| Error (Script_tc_errors.Ill_formed_type (Some "parameter", _code, _)::_) -> return Err_parameter
|
||||||
| Error (Script_tc_errors.Ill_formed_type (Some "storage", _code, _)::_) -> return Err_storage
|
| Error (Script_tc_errors.Ill_formed_type (Some "storage", _code, _)::_) -> return Err_storage
|
||||||
|
| Error (Script_tc_errors.Ill_typed_contract _ :: Script_tc_errors.Cannot_serialize_error :: []) -> return @@ Err_gas
|
||||||
| Error (Script_tc_errors.Ill_typed_contract (_code, _)::_) -> return @@ Err_contract
|
| Error (Script_tc_errors.Ill_typed_contract (_code, _)::_) -> return @@ Err_contract
|
||||||
| Error _ -> return Err_unknown
|
| Error _ -> return Err_unknown
|
||||||
|
|
||||||
|
@ -5325,8 +5325,6 @@ let typecheck_code :
|
|||||||
})
|
})
|
||||||
ctxt
|
ctxt
|
||||||
~legacy
|
~legacy
|
||||||
~type_logger:(fun loc bef aft ->
|
|
||||||
type_map := (loc, (bef, aft)) :: !type_map)
|
|
||||||
(arg_type_full, None)
|
(arg_type_full, None)
|
||||||
ret_type_full
|
ret_type_full
|
||||||
code_field
|
code_field
|
||||||
|
Loading…
Reference in New Issue
Block a user