Crash when printing error message #252

Closed
opened 2020-03-25 22:25:31 +09:00 by zxq9 · 2 comments
zxq9 commented 2020-03-25 22:25:31 +09:00 (Migrated from gitlab.com)

Created by: hanssv

Given the contract-stub:

contract HashTimeLock =
  datatype status = INVALID | ACTIVE | REFUNDED | WITHDRAWN | EXPIRED
  record lock_contract = {input_amount : int, output_amount : int, expiration : int, hash_lock : hash, status: status, sender : address, receiver : address, output_network : string, output_address : string}
  entrypoint new_contract(l : lock_contract) : lock_contract = l

The following call-result decoding fails:

./aesophia_cli /tmp/foo.aes -b fate --call_result cb_q58BgUFsUQgA37pD+/b+7SyBTPjsmp5mKp47Akx0c4yLS635b4gbwW1nTsf/wG+IG8FtZ07H/8BvhgFxEO8ARp8BgYcZ2AhdUzRj15KZWrT0vIXnJEq1gEZLA1zDge3Qam24r4UAAAAAAAE/nwCgBwwURA4zMENRZdpeBEtaqcNdLL4wyRwyFFVJN19SUmSfAKBrs4jtfFRU9fsXJtVRgxnm+6MvasbSWpfv9LbvZBN72A1BRVPRYWtfNDcxZFlVclE4RUF0bXp3dUtEdzRWQkdRZG5FY1A1WUY1NjNXRzR5UjlXdmZwNXRScCV612Q= --call_result_fun new_contract 
escript: exception error: no function clause matching 
                 aeso_pretty:type({variant_t,
                                   [{constr_t,
                                     [{file,no_file},{line,2},{col,21}],
                                     {con,
                                      [{file,no_file},{line,2},{col,21}],
                                      "INVALID"},
                                     []},
                                    {constr_t,
                                     [{file,no_file},{line,2},{col,31}],
                                     {con,
                                      [{file,no_file},{line,2},{col,31}],
                                      "ACTIVE"},
                                     []},
                                    {constr_t,
                                     [{file,no_file},{line,2},{col,40}],
                                     {con,
                                      [{file,no_file},{line,2},{col,40}],
                                      "REFUNDED"},
                                     []},
                                    {constr_t,
                                     [{file,no_file},{line,2},{col,51}],
                                     {con,
                                      [{file,no_file},{line,2},{col,51}],
                                      "WITHDRAWN"},
                                     []},
                                    {constr_t,
                                     [{file,no_file},{line,2},{col,63}],
                                     {con,
                                      [{file,no_file},{line,2},{col,63}],
                                      "EXPIRED"},
                                     []}]}) (/Users/hans/Quviq/Aeternity/aesophia_cli/_checkouts/aesophia/src/aeso_pretty.erl, line 245)
  in function  aeso_pretty:typed/2 (/Users/hans/Quviq/Aeternity/aesophia_cli/_checkouts/aesophia/src/aeso_pretty.erl, line 131)
  in call from lists:map/2 (lists.erl, line 1239)
  in call from lists:map/2 (lists.erl, line 1239)
  in call from aeso_pretty:typedef/1 (/Users/hans/Quviq/Aeternity/aesophia_cli/_checkouts/aesophia/src/aeso_pretty.erl, line 228)
  in call from aeso_compiler:to_sophia_value/5 (/Users/hans/Quviq/Aeternity/aesophia_cli/_checkouts/aesophia/src/aeso_compiler.erl, line 339)
  in call from aesophia_cli:decode_call_res/5 (/Users/hans/Quviq/Aeternity/aesophia_cli/src/aesophia_cli.erl, line 269)
  in call from aesophia_cli:main/1 (/Users/hans/Quviq/Aeternity/aesophia_cli/src/aesophia_cli.erl, line 62)

The problem comes from trying to print an error message for a variant-type that case is missing since aeso_pretty:type isn't normally called directly, but in to_sophia_value it is.

*Created by: hanssv* Given the contract-stub: ``` contract HashTimeLock = datatype status = INVALID | ACTIVE | REFUNDED | WITHDRAWN | EXPIRED record lock_contract = {input_amount : int, output_amount : int, expiration : int, hash_lock : hash, status: status, sender : address, receiver : address, output_network : string, output_address : string} entrypoint new_contract(l : lock_contract) : lock_contract = l ``` The following call-result decoding fails: ``` ./aesophia_cli /tmp/foo.aes -b fate --call_result cb_q58BgUFsUQgA37pD+/b+7SyBTPjsmp5mKp47Akx0c4yLS635b4gbwW1nTsf/wG+IG8FtZ07H/8BvhgFxEO8ARp8BgYcZ2AhdUzRj15KZWrT0vIXnJEq1gEZLA1zDge3Qam24r4UAAAAAAAE/nwCgBwwURA4zMENRZdpeBEtaqcNdLL4wyRwyFFVJN19SUmSfAKBrs4jtfFRU9fsXJtVRgxnm+6MvasbSWpfv9LbvZBN72A1BRVPRYWtfNDcxZFlVclE4RUF0bXp3dUtEdzRWQkdRZG5FY1A1WUY1NjNXRzR5UjlXdmZwNXRScCV612Q= --call_result_fun new_contract escript: exception error: no function clause matching aeso_pretty:type({variant_t, [{constr_t, [{file,no_file},{line,2},{col,21}], {con, [{file,no_file},{line,2},{col,21}], "INVALID"}, []}, {constr_t, [{file,no_file},{line,2},{col,31}], {con, [{file,no_file},{line,2},{col,31}], "ACTIVE"}, []}, {constr_t, [{file,no_file},{line,2},{col,40}], {con, [{file,no_file},{line,2},{col,40}], "REFUNDED"}, []}, {constr_t, [{file,no_file},{line,2},{col,51}], {con, [{file,no_file},{line,2},{col,51}], "WITHDRAWN"}, []}, {constr_t, [{file,no_file},{line,2},{col,63}], {con, [{file,no_file},{line,2},{col,63}], "EXPIRED"}, []}]}) (/Users/hans/Quviq/Aeternity/aesophia_cli/_checkouts/aesophia/src/aeso_pretty.erl, line 245) in function aeso_pretty:typed/2 (/Users/hans/Quviq/Aeternity/aesophia_cli/_checkouts/aesophia/src/aeso_pretty.erl, line 131) in call from lists:map/2 (lists.erl, line 1239) in call from lists:map/2 (lists.erl, line 1239) in call from aeso_pretty:typedef/1 (/Users/hans/Quviq/Aeternity/aesophia_cli/_checkouts/aesophia/src/aeso_pretty.erl, line 228) in call from aeso_compiler:to_sophia_value/5 (/Users/hans/Quviq/Aeternity/aesophia_cli/_checkouts/aesophia/src/aeso_compiler.erl, line 339) in call from aesophia_cli:decode_call_res/5 (/Users/hans/Quviq/Aeternity/aesophia_cli/src/aesophia_cli.erl, line 269) in call from aesophia_cli:main/1 (/Users/hans/Quviq/Aeternity/aesophia_cli/src/aesophia_cli.erl, line 62) ``` The problem comes from trying to print an error message for a variant-type that case is missing since `aeso_pretty:type` isn't normally called directly, but in `to_sophia_value` it is.
zxq9 commented 2020-03-26 01:19:00 +09:00 (Migrated from gitlab.com)

Created by: radrow

Btw, why doesn't the type definition contain the type name? Is there any reason to drop it down?

*Created by: radrow* Btw, why doesn't the type definition contain the type name? Is there any reason to drop it down?
zxq9 commented 2020-03-27 04:23:33 +09:00 (Migrated from gitlab.com)

Created by: radrow

@hanssv #251 should fix it. Can you check?

*Created by: radrow* @hanssv #251 should fix it. Can you check?
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#252
No description provided.