From 3fd93fc7b5c7e3f1679cbe6bb47bf579ae2802ed Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Fri, 12 Jun 2020 13:34:08 +0200 Subject: [PATCH] result monad refactoring: update test --- src/bin/expect_tests/code_insertion.ml | 34 +-- src/bin/expect_tests/contract_tests.ml | 169 ++++++++----- src/bin/expect_tests/error_messages_tests.ml | 30 +-- src/bin/expect_tests/failwith_tests.ml | 2 +- src/bin/expect_tests/lexer_tests.ml | 244 +++++++++---------- src/bin/expect_tests/literals.ml | 14 +- src/bin/expect_tests/michelson_converter.ml | 19 +- src/bin/expect_tests/michelson_or_tests.ml | 9 +- src/bin/expect_tests/misc_cli_commands.ml | 42 +++- src/bin/expect_tests/syntax_error_tests.ml | 29 +-- src/bin/expect_tests/typer_error_tests.ml | 144 +++++++---- src/passes/01-parser/formatter.ml | 2 +- 12 files changed, 445 insertions(+), 293 deletions(-) diff --git a/src/bin/expect_tests/code_insertion.ml b/src/bin/expect_tests/code_insertion.ml index 0add86ac0..6962b27cb 100644 --- a/src/bin/expect_tests/code_insertion.ml +++ b/src/bin/expect_tests/code_insertion.ml @@ -8,19 +8,21 @@ let bad_contract basename = let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_michelson_insertion_1.ligo" ; "main" ] ; [%expect{| - ligo: generated Michelson contract failed to typecheck: bad contract type - { parameter nat ; - storage nat ; - code { DUP ; - LAMBDA (pair nat nat) nat ADD ; - SWAP ; - EXEC ; - NIL operation ; - PAIR ; - DIP { DROP } } } + ligo: error + generated Michelson contract failed to typecheck : bad contract type + code: + { parameter nat ; + storage nat ; + code { DUP ; + LAMBDA (pair nat nat) nat ADD ; + SWAP ; + EXEC ; + NIL operation ; + PAIR ; + DIP { DROP } } } - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -30,11 +32,13 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_michelson_insertion_2.ligo" ; "main" ] ; [%expect{| - ligo: in file "bad_michelson_insertion_2.ligo", line 5, characters 32-40. different kinds: {"a":"nat","b":"( nat * nat )"} + ligo: error + in file "bad_michelson_insertion_2.ligo", line 3, character 0 to line 5, character 41 + Constant declaration 'main' + Bad types: expected nat got ( nat * nat ) - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index 3c5a794e6..b27434981 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -29,11 +29,17 @@ let%expect_test _ = run_ligo_bad [ "compile-storage" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ; [%expect {| - ligo: different kinds: {"a":"record[card_patterns -> (type_operator: Map (nat,record[coefficient -> mutez , quantity -> nat])) ,\n cards -> (type_operator: Map (nat,record[card_owner -> address , card_pattern -> nat])) ,\n next_id -> nat]","b":"sum[Buy_single -> record[card_to_buy -> nat] ,\n Sell_single -> record[card_to_sell -> nat] ,\n Transfer_single -> record[card_to_transfer -> nat ,\n destination -> address]]"} + ligo: error + Provided storage type does not match contract storage type + Bad types: expected record[card_patterns -> (type_operator: Map (nat,record[coefficient -> mutez , quantity -> nat])) , + cards -> (type_operator: Map (nat,record[card_owner -> address , card_pattern -> nat])) , + next_id -> nat] got sum[Buy_single -> record[card_to_buy -> nat] , + Sell_single -> record[card_to_sell -> nat] , + Transfer_single -> record[card_to_transfer -> nat , + destination -> address]] - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -42,11 +48,17 @@ let%expect_test _ = run_ligo_bad [ "compile-parameter" ; contract "coase.ligo" ; "main" ; "record cards = (map end : cards) ; card_patterns = (map end : card_patterns) ; next_id = 3n ; end" ] ; [%expect {| - ligo: different kinds: {"a":"sum[Buy_single -> record[card_to_buy -> nat] ,\n Sell_single -> record[card_to_sell -> nat] ,\n Transfer_single -> record[card_to_transfer -> nat ,\n destination -> address]]","b":"record[card_patterns -> (type_operator: Map (nat,record[coefficient -> mutez , quantity -> nat])) ,\n cards -> (type_operator: Map (nat,record[card_owner -> address , card_pattern -> nat])) ,\n next_id -> nat]"} + ligo: error + Provided parameter type does not match contract parameter type + Bad types: expected sum[Buy_single -> record[card_to_buy -> nat] , + Sell_single -> record[card_to_sell -> nat] , + Transfer_single -> record[card_to_transfer -> nat , + destination -> address]] got record[card_patterns -> (type_operator: Map (nat,record[coefficient -> mutez , quantity -> nat])) , + cards -> (type_operator: Map (nat,record[card_owner -> address , card_pattern -> nat])) , + next_id -> nat] - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1321,10 +1333,12 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; contract "bad_type_operator.ligo" ; "main" ] ; [%expect {| - ligo: bad type operator (type_operator: Map (binding)): + ligo: error + in file "bad_type_operator.ligo", line 4, characters 16-29 + unrecognized type operator (type_operator: Map (binding)) - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1334,11 +1348,12 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ; [%expect {| - ligo: in file "bad_address_format.religo", line 2, characters 26-48. Badly formatted literal: @"KT1badaddr" {"location":"in file \"bad_address_format.religo\", line 2, characters 26-48"} + ligo: error + in file "bad_address_format.religo", line 2, characters 26-48 + Badly formatted literal: @"KT1badaddr" - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1348,11 +1363,12 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; contract "bad_timestamp.ligo" ; "main" ] ; [%expect {| - ligo: in file "bad_timestamp.ligo", line 7, characters 30-44. Badly formatted timestamp "badtimestamp": {"location":"in file \"bad_timestamp.ligo\", line 7, characters 30-44"} + ligo: error + in file "bad_timestamp.ligo", line 7, characters 30-44 + Badly formatted timestamp 'badtimestamp' - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1385,10 +1401,11 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "self_in_lambda.mligo" ; "main" ] ; [%expect {| - ligo: Wrong SELF_ADDRESS location: SELF_ADDRESS is only allowed at top-level + ligo: error + SELF_ADDRESS is only allowed at top-level - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1410,10 +1427,13 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "long_sum_type_names.ligo" ; "main" ] ; [%expect {| - ligo: Too long constructor 'Incrementttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt': names length is limited to 32 (tezos limitation) + ligo: error + in file "long_sum_type_names.ligo", line 2, character 2 to line 4, character 18 + Too long constructor 'Incrementttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + names length are limited to 32 (tezos limitation) - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1428,11 +1448,15 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "redundant_constructors.mligo" ; "main" ] ; [%expect {| - ligo: redundant constructor: {"constructor":"Add","environment":"- E[]\tT[union_a -> sum[Add -> int , Remove -> int]\nbool -> sum[false -> unit , true -> unit]]"} + ligo: error + in file "redundant_constructors.mligo", line 7, character 2 to line 9, character 15 + Redundant constructor: + Add + - Env:[] Type env:[union_a -> sum[Add -> int , Remove -> int] + bool -> sum[false -> unit , true -> unit]] - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1442,11 +1466,14 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_toplevel.mligo" ; "main" ] ; [%expect {| -ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8. No free variable allowed in this lambda: variable 'store' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * string ))) : None return\n let rhs#2 = #P in\n let p = rhs#2.0 in\n let s = rhs#2.1 in\n ( LIST_EMPTY() : (type_operator: list(operation)) , store ) ,\n NONE() : (type_operator: option(key_hash)) ,\n 300000000mutez ,\n \"un\")","location":"in file \"create_contract_toplevel.mligo\", line 4, character 35 to line 8, character 8"} +ligo: error +in file "create_contract_toplevel.mligo", line 3, characters 0-3 +Constant declaration 'main' +in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8 +Free variable 'store' is not allowed in CREATE_CONTRACT lambda - If you're not sure how to fix this error, you can - do one of the following: +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1455,11 +1482,14 @@ ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_var.mligo" ; "main" ] ; [%expect {| -ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5. No free variable allowed in this lambda: variable 'a' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * int ))) : None return\n let rhs#2 = #P in\n let p = rhs#2.0 in\n let s = rhs#2.1 in\n ( LIST_EMPTY() : (type_operator: list(operation)) , a ) ,\n NONE() : (type_operator: option(key_hash)) ,\n 300000000mutez ,\n 1)","location":"in file \"create_contract_var.mligo\", line 6, character 35 to line 10, character 5"} +ligo: error +in file "create_contract_var.mligo", line 5, characters 0-3 +Constant declaration 'main' +in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5 +Free variable 'a' is not allowed in CREATE_CONTRACT lambda - If you're not sure how to fix this error, you can - do one of the following: +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1468,11 +1498,13 @@ ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, char run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_no_inline.mligo" ; "main" ] ; [%expect {| - ligo: in file "create_contract_no_inline.mligo", line 3, characters 40-46. unbound type variable: {"variable":"return","location":"in file \"create_contract_no_inline.mligo\", line 3, characters 40-46","in":"- E[foo -> int]\tT[bool -> sum[false -> unit , true -> unit]]","did_you_mean":"no suggestion"} + ligo: error + in file "create_contract_no_inline.mligo", line 3, characters 40-46 + Unbound type variable 'return' + - Env:[foo -> int] Type env:[bool -> sum[false -> unit , true -> unit]] - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1522,11 +1554,14 @@ ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, char let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "self_type_annotation.ligo" ; "main" ] ; [%expect {| - ligo: in file "self_type_annotation.ligo", line 8, characters 41-64. bad self type: expected (type_operator: Contract (int)) but got (type_operator: Contract (nat)) {"location":"in file \"self_type_annotation.ligo\", line 8, characters 41-64"} + ligo: error + in file "self_type_annotation.ligo", line 8, characters 41-64 + Bad self type + expected (type_operator: Contract (int)) + got (type_operator: Contract (nat)) - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1549,11 +1584,13 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract.mligo" ; "main" ] ; [%expect {| - ligo: in file "bad_contract.mligo", line 4, characters 0-3. badly typed contract: unexpected entrypoint type {"location":"in file \"bad_contract.mligo\", line 4, characters 0-3","entrypoint":"main","entrypoint_type":"( nat * int ) -> int"} + ligo: error + in file "bad_contract.mligo", line 4, characters 0-3 + Badly typed contract: + unexpected entrypoint type ( nat * int ) -> int - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1562,11 +1599,13 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract2.mligo" ; "main" ] ; [%expect {| - ligo: in file "bad_contract2.mligo", line 5, characters 0-3. bad return type: expected (type_operator: list(operation)), got string {"location":"in file \"bad_contract2.mligo\", line 5, characters 0-3","entrypoint":"main"} + ligo: error + in file "bad_contract2.mligo", line 5, characters 0-3 + Badly typed contract: + expected (type_operator: list(operation)) but got string - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1575,11 +1614,15 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract3.mligo" ; "main" ] ; [%expect {| - ligo: in file "bad_contract3.mligo", line 5, characters 0-3. badly typed contract: expected {int} and {string} to be the same in the entrypoint type {"location":"in file \"bad_contract3.mligo\", line 5, characters 0-3","entrypoint":"main","entrypoint_type":"( nat * int ) -> ( (type_operator: list(operation)) * string )"} + ligo: error + in file "bad_contract3.mligo", line 5, characters 0-3 + Badly typed contract main: + expected storage type as right member of a pair in the input and output, but got: + - int in the input + - string in the output - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1631,11 +1674,13 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "self_bad_entrypoint_format.ligo" ; "main" ] ; [%expect {| - ligo: in file "self_bad_entrypoint_format.ligo", line 8, characters 52-58. bad entrypoint format: entrypoint "Toto" is badly formatted. We expect "%bar" for entrypoint Bar and "%default" when no entrypoint used {"location":"in file \"self_bad_entrypoint_format.ligo\", line 8, characters 52-58"} + ligo: error + in file "self_bad_entrypoint_format.ligo", line 8, characters 52-58 + Bad entrypoint format 'Toto' + We expect '%bar' for entrypoint Bar and '%default' when no entrypoint used - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1644,11 +1689,12 @@ let%expect_test _ = run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_1.religo"; "main"]; [%expect {| - ligo: It looks like you have nested a big map inside another big map. This is not supported. : {} + ligo: error + in file "nested_bigmap_1.religo", line 1, characters 11-29 + It looks like you have nested a big map inside another big map, this is not supported - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1657,11 +1703,12 @@ let%expect_test _ = run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_2.religo"; "main"]; [%expect {| - ligo: It looks like you have nested a big map inside another big map. This is not supported. : {} + ligo: error + in file "nested_bigmap_2.religo", line 2, characters 29-50 + It looks like you have nested a big map inside another big map, this is not supported - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1670,11 +1717,12 @@ let%expect_test _ = run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_3.religo"; "main"]; [%expect {| - ligo: It looks like you have nested a big map inside another big map. This is not supported. : {} + ligo: error + in file "nested_bigmap_3.religo", line 1, characters 11-29 + It looks like you have nested a big map inside another big map, this is not supported - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -1683,11 +1731,12 @@ let%expect_test _ = run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_4.religo"; "main"]; [%expect {| - ligo: It looks like you have nested a big map inside another big map. This is not supported. : {} + ligo: error + in file "nested_bigmap_4.religo", line 2, characters 39-60 + It looks like you have nested a big map inside another big map, this is not supported - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/bin/expect_tests/error_messages_tests.ml b/src/bin/expect_tests/error_messages_tests.ml index 5f39e05b0..c5254d7da 100644 --- a/src/bin/expect_tests/error_messages_tests.ml +++ b/src/bin/expect_tests/error_messages_tests.ml @@ -3,18 +3,18 @@ open Cli_expect let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/gitlab_111.religo" ; "main" ] ; [%expect {| - ligo: : Parse error in file "gitlab_111.religo", line 2, characters 0-3 at "let", after "=": - This is an incorrect let binding. - - - Examples of correct let bindings: - let a: int = 4; - let (a: int, b: int) = (1, 2); - let func = (a: int, b: int) => a + b; - {} + ligo: error + Parse error in file "gitlab_111.religo", line 2, characters 0-3 at "let", after "=": + This is an incorrect let binding. + - + Examples of correct let bindings: + let a: int = 4; + let (a: int, b: int) = (1, 2); + let func = (a: int, b: int) => a + b; - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -23,13 +23,13 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/missing_rpar.religo" ; "main" ] ; [%expect {| - ligo: : Parse error in file "missing_rpar.religo", line 5, characters 0-3 at "let", after "m": - Missing `)`. - {} + ligo: error + Parse error in file "missing_rpar.religo", line 5, characters 0-3 at "let", after "m": + Missing `)`. - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/bin/expect_tests/failwith_tests.ml b/src/bin/expect_tests/failwith_tests.ml index 8c5819ca4..8af9d0175 100644 --- a/src/bin/expect_tests/failwith_tests.ml +++ b/src/bin/expect_tests/failwith_tests.ml @@ -12,7 +12,7 @@ let%expect_test _ = run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ; "--format=json" ] ; [%expect {| - {"status":"ok","content":"failwith(42)"} |}]; + {"value":null,"failure":"failwith(42)"} |}]; run_ligo_good [ "dry-run" ; contract "subtle_nontail_fail.mligo" ; "main" ; "()" ; "()" ] ; diff --git a/src/bin/expect_tests/lexer_tests.ml b/src/bin/expect_tests/lexer_tests.ml index 20d26ab11..412fe48f3 100644 --- a/src/bin/expect_tests/lexer_tests.ml +++ b/src/bin/expect_tests/lexer_tests.ml @@ -3,14 +3,14 @@ open Cli_expect let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.ligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "broken_string.ligo", line 1, characters 18-19: - The string starting here is interrupted by a line break. - Hint: Remove the break, close the string before or insert a backslash. - {} +ligo: error +Lexical error in file "broken_string.ligo", line 1, characters 18-19: +The string starting here is interrupted by a line break. +Hint: Remove the break, close the string before or insert a backslash. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -20,14 +20,14 @@ ligo: : Lexical error in file "broken_string.ligo", line 1, characters 18-19: run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.mligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "broken_string.mligo", line 1, characters 8-9: - The string starting here is interrupted by a line break. - Hint: Remove the break, close the string before or insert a backslash. - {} +ligo: error +Lexical error in file "broken_string.mligo", line 1, characters 8-9: +The string starting here is interrupted by a line break. +Hint: Remove the break, close the string before or insert a backslash. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -37,14 +37,14 @@ ligo: : Lexical error in file "broken_string.mligo", line 1, characters 8-9: run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.religo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "broken_string.religo", line 1, characters 8-9: - The string starting here is interrupted by a line break. - Hint: Remove the break, close the string before or insert a backslash. - {} +ligo: error +Lexical error in file "broken_string.religo", line 1, characters 8-9: +The string starting here is interrupted by a line break. +Hint: Remove the break, close the string before or insert a backslash. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -54,14 +54,14 @@ ligo: : Lexical error in file "broken_string.religo", line 1, characters 8-9: run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.ligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "negative_byte_sequence.ligo", line 1, characters 18-31: - Negative byte sequence. - Hint: Remove the leading minus sign. - {} +ligo: error +Lexical error in file "negative_byte_sequence.ligo", line 1, characters 18-31: +Negative byte sequence. +Hint: Remove the leading minus sign. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -71,14 +71,14 @@ ligo: : Lexical error in file "negative_byte_sequence.ligo", line 1, characters run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.mligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "negative_byte_sequence.mligo", line 1, characters 8-21: - Negative byte sequence. - Hint: Remove the leading minus sign. - {} +ligo: error +Lexical error in file "negative_byte_sequence.mligo", line 1, characters 8-21: +Negative byte sequence. +Hint: Remove the leading minus sign. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -88,14 +88,14 @@ ligo: : Lexical error in file "negative_byte_sequence.mligo", line 1, characters run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.religo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "negative_byte_sequence.religo", line 1, characters 8-21: - Negative byte sequence. - Hint: Remove the leading minus sign. - {} +ligo: error +Lexical error in file "negative_byte_sequence.religo", line 1, characters 8-21: +Negative byte sequence. +Hint: Remove the leading minus sign. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -124,14 +124,14 @@ ligo: : Lexical error in file "reserved_name.ligo", line 1, characters 4-13: run_ligo_bad [ "compile-contract" ; "../../test/lexer/reserved_name.religo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "reserved_name.religo", line 1, characters 4-7: - Reserved name: "end". - Hint: Change the name. - {} +ligo: error +Lexical error in file "reserved_name.religo", line 1, characters 4-7: +Reserved name: "end". +Hint: Change the name. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -141,14 +141,14 @@ ligo: : Lexical error in file "reserved_name.religo", line 1, characters 4-7: run_ligo_bad [ "compile-contract" ; "../../test/lexer/reserved_name.mligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "reserved_name.mligo", line 1, characters 4-10: - Reserved name: "object". - Hint: Change the name. - {} +ligo: error +Lexical error in file "reserved_name.mligo", line 1, characters 4-10: +Reserved name: "object". +Hint: Change the name. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -158,13 +158,13 @@ ligo: : Lexical error in file "reserved_name.mligo", line 1, characters 4-10: run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.ligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "unexpected_character.ligo", line 1, characters 18-19: - Unexpected character '\239'. - {} +ligo: error +Lexical error in file "unexpected_character.ligo", line 1, characters 18-19: +Unexpected character '\239'. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -174,13 +174,13 @@ ligo: : Lexical error in file "unexpected_character.ligo", line 1, characters 18 run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.mligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "unexpected_character.mligo", line 1, characters 8-9: - Unexpected character '\239'. - {} +ligo: error +Lexical error in file "unexpected_character.mligo", line 1, characters 8-9: +Unexpected character '\239'. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -190,13 +190,13 @@ ligo: : Lexical error in file "unexpected_character.mligo", line 1, characters 8 run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.religo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "unexpected_character.religo", line 1, characters 8-9: - Unexpected character '\239'. - {} +ligo: error +Lexical error in file "unexpected_character.religo", line 1, characters 8-9: +Unexpected character '\239'. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -206,13 +206,13 @@ ligo: : Lexical error in file "unexpected_character.religo", line 1, characters run_ligo_bad [ "compile-contract" ; "../../test/lexer/unterminated_comment.mligo" ; "main" ] ; [%expect {| -ligo: : Preprocessing error in file "../../test/lexer/unterminated_comment.mligo", line 1, characters 0-2: - Unterminated comment. - Hint: Close with "*)". {} +ligo: error +Preprocessing error in file "../../test/lexer/unterminated_comment.mligo", line 1, characters 0-2: +Unterminated comment. +Hint: Close with "*)". - If you're not sure how to fix this error, you can - do one of the following: +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -222,14 +222,14 @@ ligo: : Preprocessing error in file "../../test/lexer/unterminated_comment.mligo run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.ligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "invalid_symbol.ligo", line 1, characters 17-20: - Invalid symbol. - Hint: Check the LIGO syntax you use. - {} +ligo: error +Lexical error in file "invalid_symbol.ligo", line 1, characters 17-20: +Invalid symbol. +Hint: Check the LIGO syntax you use. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -239,14 +239,14 @@ ligo: : Lexical error in file "invalid_symbol.ligo", line 1, characters 17-20: run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.mligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "invalid_symbol.mligo", line 1, characters 10-13: - Invalid symbol. - Hint: Check the LIGO syntax you use. - {} +ligo: error +Lexical error in file "invalid_symbol.mligo", line 1, characters 10-13: +Invalid symbol. +Hint: Check the LIGO syntax you use. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -256,14 +256,14 @@ ligo: : Lexical error in file "invalid_symbol.mligo", line 1, characters 10-13: run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.religo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "invalid_symbol.religo", line 1, characters 10-11: - Invalid symbol. - Hint: Check the LIGO syntax you use. - {} +ligo: error +Lexical error in file "invalid_symbol.religo", line 1, characters 10-11: +Invalid symbol. +Hint: Check the LIGO syntax you use. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -273,14 +273,14 @@ ligo: : Lexical error in file "invalid_symbol.religo", line 1, characters 10-11: run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.ligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "missing_break.ligo", line 1, characters 18-18: - Missing break. - Hint: Insert some space. - {} +ligo: error +Lexical error in file "missing_break.ligo", line 1, characters 18-18: +Missing break. +Hint: Insert some space. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -290,14 +290,14 @@ ligo: : Lexical error in file "missing_break.ligo", line 1, characters 18-18: run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.mligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "missing_break.mligo", line 1, characters 11-11: - Missing break. - Hint: Insert some space. - {} +ligo: error +Lexical error in file "missing_break.mligo", line 1, characters 11-11: +Missing break. +Hint: Insert some space. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -307,14 +307,14 @@ ligo: : Lexical error in file "missing_break.mligo", line 1, characters 11-11: run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.religo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "missing_break.religo", line 1, characters 11-11: - Missing break. - Hint: Insert some space. - {} +ligo: error +Lexical error in file "missing_break.religo", line 1, characters 11-11: +Missing break. +Hint: Insert some space. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -324,14 +324,14 @@ ligo: : Lexical error in file "missing_break.religo", line 1, characters 11-11: run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.ligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "invalid_character_in_string.ligo", line 1, characters 19-20: - Invalid character in string. - Hint: Remove or replace the character. - {} +ligo: error +Lexical error in file "invalid_character_in_string.ligo", line 1, characters 19-20: +Invalid character in string. +Hint: Remove or replace the character. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -341,14 +341,14 @@ ligo: : Lexical error in file "invalid_character_in_string.ligo", line 1, charac run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.mligo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "invalid_character_in_string.mligo", line 1, characters 9-10: - Invalid character in string. - Hint: Remove or replace the character. - {} +ligo: error +Lexical error in file "invalid_character_in_string.mligo", line 1, characters 9-10: +Invalid character in string. +Hint: Remove or replace the character. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -358,14 +358,14 @@ ligo: : Lexical error in file "invalid_character_in_string.mligo", line 1, chara run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.religo" ; "main" ] ; [%expect {| -ligo: : Lexical error in file "invalid_character_in_string.religo", line 1, characters 9-10: - Invalid character in string. - Hint: Remove or replace the character. - {} +ligo: error +Lexical error in file "invalid_character_in_string.religo", line 1, characters 9-10: +Invalid character in string. +Hint: Remove or replace the character. - If you're not sure how to fix this error, you can - do one of the following: + +If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/bin/expect_tests/literals.ml b/src/bin/expect_tests/literals.ml index aebe463e3..e265b2437 100644 --- a/src/bin/expect_tests/literals.ml +++ b/src/bin/expect_tests/literals.ml @@ -7,11 +7,12 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad ["interpret" ; "(\"thisisnotasignature\":signature)" ; "--syntax=pascaligo"] ; [%expect {| - ligo: in file "", line 0, characters 0-33. Badly formatted literal: Signature thisisnotasignature {"location":"in file \"\", line 0, characters 0-33"} + ligo: error + in file "", line 0, characters 0-33 + Badly formatted literal: Signature thisisnotasignature - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -25,11 +26,12 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad ["interpret" ; "(\"thisisnotapublickey\":key)" ; "--syntax=pascaligo"] ; [%expect {| - ligo: in file "", line 0, characters 0-27. Badly formatted literal: key thisisnotapublickey {"location":"in file \"\", line 0, characters 0-27"} + ligo: error + in file "", line 0, characters 0-27 + Badly formatted literal: key thisisnotapublickey - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/bin/expect_tests/michelson_converter.ml b/src/bin/expect_tests/michelson_converter.ml index b8a6cd90e..b3a2a18c0 100644 --- a/src/bin/expect_tests/michelson_converter.ml +++ b/src/bin/expect_tests/michelson_converter.ml @@ -8,10 +8,13 @@ let bad_contract basename = let%expect_test _ = run_ligo_bad [ "interpret" ; "--init-file="^(bad_contract "michelson_converter_no_annotation.mligo") ; "l4"] ; [%expect {| - ligo: in file "michelson_converter_no_annotation.mligo", line 4, characters 9-39. can't retrieve type declaration order in the converted record, you need to annotate it + ligo: error + in file "michelson_converter_no_annotation.mligo", line 4, characters 9-39 + Constant declaration 'l4' + Can't retrieve type declaration order in the converted record, you need to annotate it - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -20,10 +23,14 @@ let%expect_test _ = run_ligo_bad [ "interpret" ; "--init-file="^(bad_contract "michelson_converter_short_record.mligo") ; "l1"] ; [%expect {| - ligo: in file "michelson_converter_short_record.mligo", line 4, characters 9-44. converted record must have at least two elements + ligo: error + in file "michelson_converter_short_record.mligo", line 4, characters 9-44 + Constant declaration 'l1' + in file "michelson_converter_short_record.mligo", line 1, characters 10-23 + Converted record must have at least two elements - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/bin/expect_tests/michelson_or_tests.ml b/src/bin/expect_tests/michelson_or_tests.ml index 66c49dcc0..92b7c9554 100644 --- a/src/bin/expect_tests/michelson_or_tests.ml +++ b/src/bin/expect_tests/michelson_or_tests.ml @@ -29,11 +29,14 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_michelson_or.mligo" ; "main" ] ; [%expect {| - ligo: in file "bad_michelson_or.mligo", line 6, characters 12-27. michelson_or types must be annotated: {"constructor":"M_right","location":"in file \"bad_michelson_or.mligo\", line 6, characters 12-27"} + ligo: error + in file "bad_michelson_or.mligo", line 5, characters 0-3 + Constant declaration 'main' + in file "bad_michelson_or.mligo", line 6, characters 12-27 + michelson_or contructor M_right must be annotated with a sum type - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/bin/expect_tests/misc_cli_commands.ml b/src/bin/expect_tests/misc_cli_commands.ml index ee67b18e0..2cbae54b0 100644 --- a/src/bin/expect_tests/misc_cli_commands.ml +++ b/src/bin/expect_tests/misc_cli_commands.ml @@ -13,10 +13,46 @@ let%expect_test _ = (* list-declarations *) let%expect_test _ = run_ligo_good [ "list-declarations" ; "../../test/contracts/loop.ligo" ] ; - [%expect {| {"source_file":"../../test/contracts/loop.ligo","declarations":["inner_capture_in_conditional_block","dummy","nested_for_collection_local_var","nested_for_collection","for_collection_map_k","for_collection_map_kv","for_collection_empty","for_collection_with_patches","for_collection_comp_with_acc","for_collection_proc_call","for_collection_rhs_capture","for_collection_if_and_local_var","for_collection_set","for_collection_list","for_sum_step","for_sum","while_sum","counter"]} |} ]; + [%expect {| + ../../test/contracts/loop.ligo declarations: + inner_capture_in_conditional_block + dummy + nested_for_collection_local_var + nested_for_collection + for_collection_map_k + for_collection_map_kv + for_collection_empty + for_collection_with_patches + for_collection_comp_with_acc + for_collection_proc_call + for_collection_rhs_capture + for_collection_if_and_local_var + for_collection_set + for_collection_list + for_sum_step + for_sum + while_sum + counter |} ]; + + run_ligo_good [ "list-declarations" ; "../../test/contracts/loop.mligo" ; "--format=json" ] ; + [%expect {| + {"source_file":"../../test/contracts/loop.mligo","declarations":["counter_nest","aux_nest","counter","counter_simple","aux_simple"]} |} ]; + run_ligo_good [ "list-declarations" ; "../../test/contracts/loop.mligo" ] ; - [%expect {| {"source_file":"../../test/contracts/loop.mligo","declarations":["counter_nest","aux_nest","counter","counter_simple","aux_simple"]} |} ]; + [%expect {| + ../../test/contracts/loop.mligo declarations: + counter_nest + aux_nest + counter + counter_simple + aux_simple |} ]; run_ligo_good [ "list-declarations" ; "../../test/contracts/loop.religo" ] ; - [%expect {| {"source_file":"../../test/contracts/loop.religo","declarations":["counter_nest","aux_nest","counter","counter_simple","aux_simple"]} |} ]; + [%expect {| + ../../test/contracts/loop.religo declarations: + counter_nest + aux_nest + counter + counter_simple + aux_simple |} ]; diff --git a/src/bin/expect_tests/syntax_error_tests.ml b/src/bin/expect_tests/syntax_error_tests.ml index 0968c1d5b..7b1bcb09d 100644 --- a/src/bin/expect_tests/syntax_error_tests.ml +++ b/src/bin/expect_tests/syntax_error_tests.ml @@ -3,12 +3,12 @@ open Cli_expect let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_syntax.ligo" ; "main" ] ; [%expect {| - ligo: : Parse error in file "error_syntax.ligo", line 1, characters 16-17 at "-", after "bar": - 16: {} + ligo: error + Parse error in file "error_syntax.ligo", line 1, characters 16-17 at "-", after "bar": + 16: - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -17,17 +17,18 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_function_arguments.religo" ; "main" ] ; [%expect {| - ligo: in file "error_function_arguments.religo", line 1, characters 14-27. : It looks like you are defining a function, however we do not - understand the parameters declaration. - Examples of valid functions: - let x = (a: string, b: int) : int => 3; - let tuple = ((a, b): (int, int)) => a + b; - let x = (a: string) : string => "Hello, " ++ a; - {"location":"in file \"error_function_arguments.religo\", line 1, characters 14-27"} - + ligo: error + in file "error_function_arguments.religo", line 1, characters 14-27 + It looks like you are defining a function, however we do not + understand the parameters declaration. + Examples of valid functions: + let x = (a: string, b: int) : int => 3; + let tuple = ((a, b): (int, int)) => a + b; + let x = (a: string) : string => "Hello, " ++ a; - If you're not sure how to fix this error, you can - do one of the following: + + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/bin/expect_tests/typer_error_tests.ml b/src/bin/expect_tests/typer_error_tests.ml index c8690a3e5..182b54235 100644 --- a/src/bin/expect_tests/typer_error_tests.ml +++ b/src/bin/expect_tests/typer_error_tests.ml @@ -3,11 +3,13 @@ open Cli_expect let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_function_annotation_1.mligo"; "main"]; [%expect {| - ligo: in file "error_function_annotation_1.mligo", line 1, characters 0-3. different type constructors: Expected these two constant type constructors to be the same, but they're different {"a":"unit","b":"int"} + ligo: error + in file "error_function_annotation_1.mligo", line 1, characters 0-3 + Constant declaration 'main' + Bad types: expected int -> unit got int -> int - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -16,11 +18,13 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_function_annotation_2.mligo"; "f"]; [%expect {| - ligo: in file "error_function_annotation_2.mligo", line 1, characters 14-43. different kinds: {"a":"int","b":"( int * int ) -> int"} + ligo: error + in file "error_function_annotation_2.mligo", line 1, characters 14-43 + Constant declaration 'f' + Bad types: expected int got ( int * int ) -> int - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -29,11 +33,18 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_function_annotation_3.mligo"; "f"]; [%expect {| - ligo: in file "error_function_annotation_3.mligo", line 6, characters 0-3. different kinds: {"a":"( (type_operator: list(operation)) * sum[Add -> int , Sub -> int] )","b":"sum[Add -> int , Sub -> int]"} + ligo: error + in file "error_function_annotation_3.mligo", line 6, characters 0-3 + Constant declaration 'main' + Bad types: expected ( int * sum[Add -> int , Sub -> int] ) -> ( (type_operator: list(operation)) * + sum[Add -> int , + Sub -> int] ) got ( int * + sum[Add -> int , + Sub -> int] ) -> sum[Add -> int , + Sub -> int] - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -42,11 +53,12 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_no_tail_recursive_function.mligo"; "f"]; [%expect {| - ligo: in file "error_no_tail_recursive_function.mligo", line 2, characters 14-21. Recursion must be achieved through tail-calls only: {"function":"unvalid","location":"in file \"error_no_tail_recursive_function.mligo\", line 2, characters 14-21"} + ligo: error + in file "error_no_tail_recursive_function.mligo", line 2, characters 14-21 + Recursion must be achieved through tail-calls only - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -55,10 +67,15 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_type.ligo" ; "main" ] ; [%expect {| - ligo: in file "error_type.ligo", line 3, characters 18-28. Adding modulo with wrong types: Expected arguments with one of the following combinations of types: add(nat , nat) or add(int , int) or add(mutez , mutez) or add(nat , int) or add(int , nat) or add(timestamp , int) or add(int , timestamp) but got this combination instead: add(int , string) + ligo: error + in file "error_type.ligo", line 3, characters 18-28 + Constant declaration 'foo' + Expected arguments with one of the following combinations of type: + (nat , nat) or (int , int) or (mutez , mutez) or (nat , int) or (int , nat) or (timestamp , int) or (int , timestamp) + but got int , string - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -67,11 +84,13 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_1.mligo" ; "main" ] ; [%expect {| - ligo: in file "error_typer_1.mligo", line 3, characters 19-27. different type constructors: Expected these two constant type constructors to be the same, but they're different {"a":"string","b":"int"} + ligo: error + in file "error_typer_1.mligo", line 3, characters 19-27 + Constant declaration 'foo' + Bad types: expected string got int - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -80,11 +99,13 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_2.mligo" ; "main" ] ; [%expect {| - ligo: in file "error_typer_2.mligo", line 3, characters 24-39. different type constructors: Expected these two n-ary type constructors to be the same, but they're different {"a":"(type_operator: list(string))","b":"(type_operator: option(int))"} + ligo: error + in file "error_typer_2.mligo", line 3, characters 24-39 + Constant declaration 'foo' + Bad types: expected (type_operator: list(string)) got (type_operator: option(int)) - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -93,11 +114,14 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_3.mligo" ; "main" ] ; [%expect {| - ligo: in file "error_typer_3.mligo", line 3, characters 34-53. tuples have different sizes: Expected these two types to be the same, but they're different (both are tuples, but with a different number of arguments) {"a":"( int * string * sum[false -> unit , true -> unit] )","b":"( int * string )"} + ligo: error + in file "error_typer_3.mligo", line 3, characters 34-53 + Constant declaration 'foo' + Bad types: expected ( int * string * sum[false -> unit , true -> unit] ) got ( int * + string ) - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -106,11 +130,18 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_4.mligo" ; "main" ] ; [%expect {| - ligo: in file "error_typer_4.mligo", line 4, characters 17-56. different keys in records: {"key_a":"c","key_b":"b","a":"record[a -> int , c -> sum[false -> unit , true -> unit] , d -> string]","b":"record[a -> int , b -> string , c -> sum[false -> unit , true -> unit]]"} + ligo: error + in file "error_typer_4.mligo", line 4, characters 17-56 + Constant declaration 'foo' + Bad types: expected record[a -> int , + c -> sum[false -> unit , true -> unit] , + d -> string] got record[a -> int , + b -> string , + c -> sum[false -> unit , + true -> unit]] - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -119,11 +150,13 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_5.mligo" ; "main" ] ; [%expect {| - ligo: in file "error_typer_5.mligo", line 1, characters 10-17. unbound type variable: {"variable":"boolean","location":"in file \"error_typer_5.mligo\", line 1, characters 10-17","in":"- E[]\tT[bool -> sum[false -> unit , true -> unit]]","did_you_mean":"bool"} + ligo: error + in file "error_typer_5.mligo", line 1, characters 10-17 + Unbound type variable 'boolean' + - Env:[] Type env:[bool -> sum[false -> unit , true -> unit]] - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -132,11 +165,13 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_6.mligo" ; "main" ] ; [%expect {| - ligo: in file "error_typer_6.mligo", line 1, characters 30-64. different kinds: {"a":"string","b":"sum[false -> unit , true -> unit]"} + ligo: error + in file "error_typer_6.mligo", line 1, characters 30-64 + Constant declaration 'foo' + Bad types: expected (type_operator: Map (int,string)) got (type_operator: Map (int,sum[false -> unit , true -> unit])) - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -145,11 +180,16 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_7.mligo" ; "main" ] ; [%expect {| - ligo: in file "error_typer_7.mligo", line 4, characters 18-48. records have different sizes: Expected these two types to be the same, but they're different (both are records, but with a different number of arguments) {"a":"record[a -> int , b -> string]","b":"record[a -> int , b -> string , c -> sum[false -> unit , true -> unit]]"} + ligo: error + in file "error_typer_7.mligo", line 4, characters 17-56 + Constant declaration 'foo' + Bad types: expected record[a -> int , b -> string] got record[a -> int , + b -> string , + c -> sum[false -> unit , + true -> unit]] - If you're not sure how to fix this error, you can - do one of the following: + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -158,12 +198,16 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/id.mligo" ; "main" ] ; [%expect {| - ligo: in file "id.mligo", line 45, characters 4-51. Expected a different type: Expected the type option but got the type record[controller -> address , - owner -> address , - profile -> bytes] + ligo: error + in file "id.mligo", line 28, characters 0-3 + Constant declaration 'buy' + in file "id.mligo", line 3, character 18 to line 7, character 1 + Expected an option but got record[controller -> address , + owner -> address , + profile -> bytes] - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -181,10 +225,11 @@ let%expect_test _ = run_ligo_bad [ "interpret" ; "Set.literal [ (1,2,3) ; (2,3,4) ]" ; "--syntax=cameligo" ] ; [%expect {| - ligo: not a comparable type: pair (use (a,(b,c)) instead of (a,b,c)) + ligo: error + pair does not have a comparable structure. (hint: use (a,(b,c)) instead of (a,b,c)) - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt @@ -194,10 +239,15 @@ let%expect_test _ = let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/failwith_wrong_type.ligo" ; "main" ] ; [%expect {| - ligo: in file "failwith_wrong_type.ligo", line 2, characters 19-46. Failwith with disallowed type: Expected arguments with one of the following combinations of types: failwith(string) or failwith(nat) or failwith(int) but got this combination instead: failwith((type_operator: list(int))) + ligo: error + in file "failwith_wrong_type.ligo", line 2, characters 19-46 + Constant declaration 'bad' + Expected arguments with one of the following combinations of type: + (string) or (nat) or (int) + but got (type_operator: list(int)) - If you're not sure how to fix this error, you can - do one of the following: + + If you're not sure how to fix this error, you can do one of the following: * Visit our documentation: https://ligolang.org/docs/intro/introduction * Ask a question on our Discord: https://discord.gg/9rhYaEt diff --git a/src/passes/01-parser/formatter.ml b/src/passes/01-parser/formatter.ml index 14a16b7aa..9d43eb119 100644 --- a/src/passes/01-parser/formatter.ml +++ b/src/passes/01-parser/formatter.ml @@ -2,7 +2,7 @@ open Display let ppx_ppformat ~display_format f (buf,_) = match display_format with - | Human_readable | Dev -> Format.fprintf f "%s\n" (Buffer.contents buf) + | Human_readable | Dev -> Format.fprintf f "%s" (Buffer.contents buf) let ppx_jsonformat (buf,_) : json = let s = Format.asprintf "%s" (Buffer.contents buf) in