From 49f9ef955f9b165ffe453759a4a60bed166c74fe Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Mon, 18 Nov 2019 11:55:04 +0100 Subject: [PATCH] Prefix format annotation for negative numbers --- src/aeso_vm_decode.erl | 4 ++-- test/aeso_abi_tests.erl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aeso_vm_decode.erl b/src/aeso_vm_decode.erl index 827aed4..d25512e 100644 --- a/src/aeso_vm_decode.erl +++ b/src/aeso_vm_decode.erl @@ -20,7 +20,7 @@ from_aevm(word, {app_t, _, {id, _, "oracle_query"}, _}, N) -> address_literal(or from_aevm(word, {con, _, _Name}, N) -> address_literal(contract_pubkey, N); from_aevm(word, {id, _, "int"}, N0) -> <> = <>, - if N < 0 -> {app, [], {'-', []}, [{int, [], -N}]}; + if N < 0 -> {app, [{format, prefix}], {'-', []}, [{int, [], -N}]}; true -> {int, [], N} end; from_aevm(word, {id, _, "bits"}, N0) -> <> = <>, @@ -78,7 +78,7 @@ from_fate({con, _, _Name}, ?FATE_CONTRACT(Bin)) -> {contract_pubkey, [], Bin}; from_fate({bytes_t, _, N}, ?FATE_BYTES(Bin)) when byte_size(Bin) == N -> {bytes, [], Bin}; from_fate({id, _, "bits"}, ?FATE_BITS(N)) -> make_bits(N); from_fate({id, _, "int"}, N) when is_integer(N) -> - if N < 0 -> {app, [], {'-', []}, [{int, [], -N}]}; + if N < 0 -> {app, [{format, prefix}], {'-', []}, [{int, [], -N}]}; true -> {int, [], N} end; from_fate({id, _, "bool"}, B) when is_boolean(B) -> {bool, [], B}; from_fate({id, _, "string"}, S) when is_binary(S) -> {string, [], S}; diff --git a/test/aeso_abi_tests.erl b/test/aeso_abi_tests.erl index ce04b33..6f1fb02 100644 --- a/test/aeso_abi_tests.erl +++ b/test/aeso_abi_tests.erl @@ -62,7 +62,7 @@ encode_decode_sophia_test() -> Other -> Other end end, ok = Check("int", "42"), - ok = Check("int", "-42"), + ok = Check("int", "- 42"), ok = Check("bool", "true"), ok = Check("bool", "false"), ok = Check("string", "\"Hello\""),