Merge branch 'hotfix' into 'dev'

Hotfix: display errors, fix mystery `fail`

See merge request ligolang/ligo!93
This commit is contained in:
Tom Jack 2019-09-26 11:41:53 +00:00
commit 288b7e9149
3 changed files with 6 additions and 5 deletions

View File

@ -10,7 +10,7 @@ let toplevel ~(display_format : string) (x : string result) =
) )
in in
match x with match x with
| Ok _ -> Format.printf "%a" (formatted_string_result_pp display_format) x | Ok _ -> Format.printf "%a\n%!" (formatted_string_result_pp display_format) x
| Error _ -> | Error _ ->
Format.eprintf "%a" (formatted_string_result_pp display_format) x ; Format.eprintf "%a\n%!" (formatted_string_result_pp display_format) x ;
exit 1 exit 1

View File

@ -703,6 +703,7 @@ module Compiler = struct
("MAP_UPDATE" , simple_ternary @@ prim I_UPDATE) ; ("MAP_UPDATE" , simple_ternary @@ prim I_UPDATE) ;
("SIZE" , simple_unary @@ prim I_SIZE) ; ("SIZE" , simple_unary @@ prim I_SIZE) ;
("FAILWITH" , simple_unary @@ prim I_FAILWITH) ; ("FAILWITH" , simple_unary @@ prim I_FAILWITH) ;
("ASSERT_INFERRED" , simple_binary @@ i_if (seq [i_failwith]) (seq [i_drop ; i_push_unit])) ;
("ASSERT" , simple_unary @@ i_if (seq [i_push_unit]) (seq [i_push_unit ; i_failwith])) ; ("ASSERT" , simple_unary @@ i_if (seq [i_push_unit]) (seq [i_push_unit ; i_failwith])) ;
("INT" , simple_unary @@ prim I_INT) ; ("INT" , simple_unary @@ prim I_INT) ;
("ABS" , simple_unary @@ prim I_ABS) ; ("ABS" , simple_unary @@ prim I_ABS) ;

View File

@ -41,7 +41,7 @@ function transfer_single(const action : action_transfer_single ; const s : stora
begin begin
const cards : cards = s.cards ; const cards : cards = s.cards ;
const card : card = get_force(action.card_to_transfer , cards) ; const card : card = get_force(action.card_to_transfer , cards) ;
if (card.card_owner =/= source) then failwith("This card doesn't belong to you") else skip ; if (card.card_owner =/= source) then fail "This card doesn't belong to you" else skip ;
card.card_owner := action.destination ; card.card_owner := action.destination ;
cards[action.card_to_transfer] := card ; cards[action.card_to_transfer] := card ;
s.cards := cards ; s.cards := cards ;
@ -51,7 +51,7 @@ function transfer_single(const action : action_transfer_single ; const s : stora
function sell_single(const action : action_sell_single ; const s : storage_type) : (list(operation) * storage_type) is function sell_single(const action : action_sell_single ; const s : storage_type) : (list(operation) * storage_type) is
begin begin
const card : card = get_force(action.card_to_sell , s.cards) ; const card : card = get_force(action.card_to_sell , s.cards) ;
if (card.card_owner =/= source) then failwith("This card doesn't belong to you") else skip ; if (card.card_owner =/= source) then fail "This card doesn't belong to you" else skip ;
const card_pattern : card_pattern = get_force(card.card_pattern , s.card_patterns) ; const card_pattern : card_pattern = get_force(card.card_pattern , s.card_patterns) ;
card_pattern.quantity := abs(card_pattern.quantity - 1n); card_pattern.quantity := abs(card_pattern.quantity - 1n);
const card_patterns : card_patterns = s.card_patterns ; const card_patterns : card_patterns = s.card_patterns ;
@ -71,7 +71,7 @@ function buy_single(const action : action_buy_single ; const s : storage_type) :
// Check funds // Check funds
const card_pattern : card_pattern = get_force(action.card_to_buy , s.card_patterns) ; const card_pattern : card_pattern = get_force(action.card_to_buy , s.card_patterns) ;
const price : tez = card_pattern.coefficient * (card_pattern.quantity + 1n) ; const price : tez = card_pattern.coefficient * (card_pattern.quantity + 1n) ;
if (price > amount) then failwith("Not enough money") else skip ; if (price > amount) then fail "Not enough money" else skip ;
// Administrative procedure // Administrative procedure
const operations : list(operation) = nil ; const operations : list(operation) = nil ;
// Increase quantity // Increase quantity