From ab773a56a4a02f8eceeb36a1cf8b02f361aa0e4a Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Wed, 1 Jul 2020 17:52:13 +0200 Subject: [PATCH 1/2] errors are printed to std err: this has the weird side effect to indent the error after 'ligo: error' --- src/bin/cli.ml | 4 +- src/bin/cli_helpers.ml | 23 +- src/bin/cli_helpers.mli | 3 +- src/bin/expect_tests/code_insertion.ml | 48 +-- src/bin/expect_tests/contract_tests.ml | 320 ++++++++--------- src/bin/expect_tests/error_messages_tests.ml | 38 +- src/bin/expect_tests/lexer_tests.ml | 330 +++++++++--------- src/bin/expect_tests/literals.ml | 28 +- src/bin/expect_tests/michelson_converter.ml | 34 +- src/bin/expect_tests/michelson_or_tests.ml | 18 +- src/bin/expect_tests/syntax_error_tests.ml | 38 +- src/bin/expect_tests/typer_error_tests.ml | 288 +++++++-------- .../09-typing/08-typer-common/errors.ml | 4 +- 13 files changed, 588 insertions(+), 588 deletions(-) diff --git a/src/bin/cli.ml b/src/bin/cli.ml index 1da631669..62bb17c79 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -257,7 +257,7 @@ let measure_contract = let%bind contract = Compile.Utils.compile_file source_file syntax entry_point in ok @@ Tezos_utils.Michelson.measure contract in let format = Display.bind_format Formatter.contract_size_format Main.Formatter.error_format in - toplevel ~display_format (Display.Displayable { value ; format }) (returned_value value) + toplevel ~display_format (Display.Displayable { value ; format }) value in let term = Term.(const f $ source_file 0 $ entry_point 1 $ syntax $ display_format) in @@ -436,7 +436,7 @@ let dump_changelog = let f display_format = let value = [%blob "../../CHANGELOG.md"] in let format = Formatter.changelog_format in - toplevel ~display_format (Display.Displayable {value ; format}) (returned_value (ok ())) in + toplevel ~display_format (Display.Displayable {value ; format}) (ok value) in let term = Term.(const f $ display_format) in let cmdname = "changelog" in diff --git a/src/bin/cli_helpers.ml b/src/bin/cli_helpers.ml index 6bf5c96d7..46a948220 100644 --- a/src/bin/cli_helpers.ml +++ b/src/bin/cli_helpers.ml @@ -1,23 +1,24 @@ open Cmdliner open Main.Display -let returned_value : (_,_) result -> unit -> unit Term.ret = - fun v () -> match v with - | Ok _ -> `Ok () - | Error _ -> `Error (false, "error") +let return_good v = `Ok v +let return_bad v = `Error (false, Format.asprintf "@[error@ %s@]" v) -let toplevel : display_format:ex_display_format -> displayable -> (unit -> unit Term.ret) -> unit Term.ret = - fun ~display_format disp return -> +let toplevel : display_format:ex_display_format -> displayable -> ('value, Main_errors.Types.all) result -> unit Term.ret = + fun ~display_format disp value -> let (Ex_display_format t) = display_format in let as_str : string = match t with | Human_readable -> convert ~display_format:t disp ; | Dev -> convert ~display_format:t disp ; - | Json -> Yojson.to_string @@ convert ~display_format:t disp in - Format.printf "%s\n" as_str ; - return () + | Json -> Yojson.to_string @@ convert ~display_format:t disp + in + match value with + | Ok _ -> return_good @@ + Format.fprintf Format.std_formatter "%s\n" as_str + | Error _ -> return_bad as_str let return_result : display_format:ex_display_format -> 'value format -> ('value, Main_errors.Types.all) result -> unit Term.ret = fun ~display_format value_format value -> - let format = Display.bind_format value_format Main.Formatter.error_format in - toplevel ~display_format (Display.Displayable {value ; format}) (returned_value value) \ No newline at end of file + let format = bind_format value_format Main.Formatter.error_format in + toplevel ~display_format (Displayable {value ; format}) value \ No newline at end of file diff --git a/src/bin/cli_helpers.mli b/src/bin/cli_helpers.mli index 166394f65..a863f45a9 100644 --- a/src/bin/cli_helpers.mli +++ b/src/bin/cli_helpers.mli @@ -1,6 +1,5 @@ open Cmdliner open Display -val toplevel : display_format:ex_display_format -> displayable -> (unit -> unit Term.ret) -> unit Term.ret -val returned_value : (_,_) Trace.result -> unit -> unit Term.ret +val toplevel : display_format:ex_display_format -> displayable -> ('value, Main_errors.Types.all) result -> unit Term.ret val return_result : display_format:ex_display_format -> 'value format -> ('value, Main_errors.Types.all) result -> unit Term.ret \ No newline at end of file diff --git a/src/bin/expect_tests/code_insertion.ml b/src/bin/expect_tests/code_insertion.ml index beb9dcd30..78a27def7 100644 --- a/src/bin/expect_tests/code_insertion.ml +++ b/src/bin/expect_tests/code_insertion.ml @@ -9,41 +9,41 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_michelson_insertion_1.ligo" ; "main" ] ; [%expect{| 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 } } } + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_michelson_insertion_2.ligo" ; "main" ] ; [%expect{| ligo: error - in file "bad_michelson_insertion_2.ligo", line 3, characters 9-13 - Constant declaration 'main' - Bad types: expected nat got ( nat * nat ) + in file "bad_michelson_insertion_2.ligo", line 3, characters 9-13 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_good [ "compile-contract" ; bad_contract "bad_michelson_insertion_3.ligo" ; "main" ] ; diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index d77df3a0c..a1a0f538f 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -30,34 +30,34 @@ let%expect_test _ = run_ligo_bad [ "compile-storage" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ; [%expect {| 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]] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; 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: 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] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; () @@ -1328,46 +1328,46 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; contract "bad_type_operator.ligo" ; "main" ] ; [%expect {| ligo: error - in file "bad_type_operator.ligo", line 4, characters 16-29 - unrecognized type operator (type_operator: Map (binding)) + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ; [%expect {| ligo: error - in file "bad_address_format.religo", line 2, characters 26-48 - Badly formatted literal: @"KT1badaddr" + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_bad [ "compile-contract" ; contract "bad_timestamp.ligo" ; "main" ] ; [%expect {| ligo: error - in file "bad_timestamp.ligo", line 7, characters 30-44 - Badly formatted timestamp 'badtimestamp' + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_good [ "dry-run" ; contract "redeclaration.ligo" ; "main" ; "unit" ; "0" ] ; @@ -1396,15 +1396,15 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "self_in_lambda.mligo" ; "main" ] ; [%expect {| ligo: error - SELF_ADDRESS is only allowed at top-level + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_good [ "compile-storage" ; contract "big_map.ligo" ; "main" ; "(big_map1,unit)" ] ; @@ -1422,17 +1422,17 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "long_sum_type_names.ligo" ; "main" ] ; [%expect {| 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) + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_good [ "dry-run" ; contract "super-counter.mligo" ; "main" ; "test_param" ; "test_storage" ] ; @@ -1443,67 +1443,67 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "redundant_constructors.mligo" ; "main" ] ; [%expect {| 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]] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_toplevel.mligo" ; "main" ] ; [%expect {| ligo: error -in file "create_contract_toplevel.mligo", line 3, characters 4-8 -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 + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_var.mligo" ; "main" ] ; [%expect {| ligo: error -in file "create_contract_var.mligo", line 5, characters 4-8 -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 + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_no_inline.mligo" ; "main" ] ; [%expect {| 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]] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; run_ligo_good [ "compile-contract" ; contract "create_contract.mligo" ; "main" ] ; [%expect {| @@ -1549,18 +1549,18 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "self_type_annotation.ligo" ; "main" ] ; [%expect {| 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)) + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; run_ligo_good [ "compile-contract" ; contract "self_type_annotation.ligo" ; "main" ] ; [%expect {| @@ -1579,49 +1579,49 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract.mligo" ; "main" ] ; [%expect {| ligo: error - in file "bad_contract.mligo", line 4, characters 0-3 - Badly typed contract: - unexpected entrypoint type ( nat * int ) -> int + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract2.mligo" ; "main" ] ; [%expect {| ligo: error - in file "bad_contract2.mligo", line 5, characters 0-3 - Badly typed contract: - expected (type_operator: list(operation)) but got string + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract3.mligo" ; "main" ] ; [%expect {| 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 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_good [ "compile-contract" ; contract "self_with_entrypoint.ligo" ; "main" ] ; @@ -1669,73 +1669,73 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "self_bad_entrypoint_format.ligo" ; "main" ] ; [%expect {| 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 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_1.religo"; "main"]; [%expect {| 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 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_2.religo"; "main"]; [%expect {| 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 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_3.religo"; "main"]; [%expect {| 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 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_4.religo"; "main"]; [%expect {| 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 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_good ["print-ast"; contract "letin.mligo"]; [%expect {| diff --git a/src/bin/expect_tests/error_messages_tests.ml b/src/bin/expect_tests/error_messages_tests.ml index c5254d7da..861a78374 100644 --- a/src/bin/expect_tests/error_messages_tests.ml +++ b/src/bin/expect_tests/error_messages_tests.ml @@ -4,35 +4,35 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/gitlab_111.religo" ; "main" ] ; [%expect {| 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; + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/missing_rpar.religo" ; "main" ] ; [%expect {| ligo: error - Parse error in file "missing_rpar.religo", line 5, characters 0-3 at "let", after "m": - Missing `)`. + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; diff --git a/src/bin/expect_tests/lexer_tests.ml b/src/bin/expect_tests/lexer_tests.ml index 412fe48f3..34b9cfd36 100644 --- a/src/bin/expect_tests/lexer_tests.ml +++ b/src/bin/expect_tests/lexer_tests.ml @@ -4,103 +4,103 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.ligo" ; "main" ] ; [%expect {| 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. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.mligo" ; "main" ] ; [%expect {| 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. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.religo" ; "main" ] ; [%expect {| 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. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.ligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "negative_byte_sequence.ligo", line 1, characters 18-31: -Negative byte sequence. -Hint: Remove the leading minus sign. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.mligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "negative_byte_sequence.mligo", line 1, characters 8-21: -Negative byte sequence. -Hint: Remove the leading minus sign. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.religo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "negative_byte_sequence.religo", line 1, characters 8-21: -Negative byte sequence. -Hint: Remove the leading minus sign. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; (* @@ -125,250 +125,250 @@ 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: error -Lexical error in file "reserved_name.religo", line 1, characters 4-7: -Reserved name: "end". -Hint: Change the name. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/reserved_name.mligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "reserved_name.mligo", line 1, characters 4-10: -Reserved name: "object". -Hint: Change the name. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.ligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "unexpected_character.ligo", line 1, characters 18-19: -Unexpected character '\239'. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.mligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "unexpected_character.mligo", line 1, characters 8-9: -Unexpected character '\239'. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.religo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "unexpected_character.religo", line 1, characters 8-9: -Unexpected character '\239'. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/unterminated_comment.mligo" ; "main" ] ; [%expect {| ligo: error -Preprocessing error in file "../../test/lexer/unterminated_comment.mligo", line 1, characters 0-2: -Unterminated comment. -Hint: Close with "*)". + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.ligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "invalid_symbol.ligo", line 1, characters 17-20: -Invalid symbol. -Hint: Check the LIGO syntax you use. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.mligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "invalid_symbol.mligo", line 1, characters 10-13: -Invalid symbol. -Hint: Check the LIGO syntax you use. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.religo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "invalid_symbol.religo", line 1, characters 10-11: -Invalid symbol. -Hint: Check the LIGO syntax you use. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.ligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "missing_break.ligo", line 1, characters 18-18: -Missing break. -Hint: Insert some space. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.mligo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "missing_break.mligo", line 1, characters 11-11: -Missing break. -Hint: Insert some space. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.religo" ; "main" ] ; [%expect {| ligo: error -Lexical error in file "missing_break.religo", line 1, characters 11-11: -Missing break. -Hint: Insert some space. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.ligo" ; "main" ] ; [%expect {| 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. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.mligo" ; "main" ] ; [%expect {| 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. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ]; run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.religo" ; "main" ] ; [%expect {| 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. + 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 -* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new -* Check the changelog by running 'ligo changelog' + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] diff --git a/src/bin/expect_tests/literals.ml b/src/bin/expect_tests/literals.ml index e265b2437..709ff68cc 100644 --- a/src/bin/expect_tests/literals.ml +++ b/src/bin/expect_tests/literals.ml @@ -8,16 +8,16 @@ let%expect_test _ = run_ligo_bad ["interpret" ; "(\"thisisnotasignature\":signature)" ; "--syntax=pascaligo"] ; [%expect {| ligo: error - in file "", line 0, characters 0-33 - Badly formatted literal: Signature thisisnotasignature + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_good ["interpret" ; "(\"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav\":key)" ; "--syntax=pascaligo"] ; @@ -27,13 +27,13 @@ let%expect_test _ = run_ligo_bad ["interpret" ; "(\"thisisnotapublickey\":key)" ; "--syntax=pascaligo"] ; [%expect {| ligo: error - in file "", line 0, characters 0-27 - Badly formatted literal: key thisisnotapublickey + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] diff --git a/src/bin/expect_tests/michelson_converter.ml b/src/bin/expect_tests/michelson_converter.ml index 1cad63e45..6026232ce 100644 --- a/src/bin/expect_tests/michelson_converter.ml +++ b/src/bin/expect_tests/michelson_converter.ml @@ -9,33 +9,33 @@ let%expect_test _ = run_ligo_bad [ "interpret" ; "--init-file="^(bad_contract "michelson_converter_no_annotation.mligo") ; "l4"] ; [%expect {| ligo: error - in file "michelson_converter_no_annotation.mligo", line 4, characters 4-6 - Constant declaration 'l4' - Can't retrieve type declaration order in the converted record, you need to annotate it + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] ; run_ligo_bad [ "interpret" ; "--init-file="^(bad_contract "michelson_converter_short_record.mligo") ; "l1"] ; [%expect {| ligo: error - in file "michelson_converter_short_record.mligo", line 4, characters 4-6 - Constant declaration 'l1' - in file "michelson_converter_short_record.mligo", line 1, characters 10-23 - Converted record must have at least two elements + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_good [ "interpret" ; "--init-file="^(contract "michelson_converter_pair.mligo") ; "r3"] ; diff --git a/src/bin/expect_tests/michelson_or_tests.ml b/src/bin/expect_tests/michelson_or_tests.ml index 6fe517e04..1ba993740 100644 --- a/src/bin/expect_tests/michelson_or_tests.ml +++ b/src/bin/expect_tests/michelson_or_tests.ml @@ -30,18 +30,18 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; bad_contract "bad_michelson_or.mligo" ; "main" ] ; [%expect {| ligo: error - in file "bad_michelson_or.mligo", line 5, characters 4-8 - 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 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_good [ "compile-contract" ; contract "michelson_or_tree_intermediary.ligo" ; "main" ] ; diff --git a/src/bin/expect_tests/syntax_error_tests.ml b/src/bin/expect_tests/syntax_error_tests.ml index 7b1bcb09d..ae5daae73 100644 --- a/src/bin/expect_tests/syntax_error_tests.ml +++ b/src/bin/expect_tests/syntax_error_tests.ml @@ -4,34 +4,34 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_syntax.ligo" ; "main" ] ; [%expect {| ligo: error - Parse error in file "error_syntax.ligo", line 1, characters 16-17 at "-", after "bar": - 16: + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_function_arguments.religo" ; "main" ] ; [%expect {| 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; + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; diff --git a/src/bin/expect_tests/typer_error_tests.ml b/src/bin/expect_tests/typer_error_tests.ml index 4d5ea615b..6c01b79b8 100644 --- a/src/bin/expect_tests/typer_error_tests.ml +++ b/src/bin/expect_tests/typer_error_tests.ml @@ -4,211 +4,211 @@ let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_function_annotation_1.mligo"; "main"]; [%expect {| ligo: error - in file "error_function_annotation_1.mligo", line 1, characters 4-8 - Constant declaration 'main' - Bad types: expected int -> unit got int -> int + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_function_annotation_2.mligo"; "f"]; [%expect {| ligo: error - in file "error_function_annotation_2.mligo", line 1, characters 4-5 - Constant declaration 'f' - Bad types: expected int got ( int * int ) -> int + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_function_annotation_3.mligo"; "f"]; [%expect {| ligo: error - in file "error_function_annotation_3.mligo", line 6, characters 4-8 - 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] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_no_tail_recursive_function.mligo"; "f"]; [%expect {| ligo: error - in file "error_no_tail_recursive_function.mligo", line 2, characters 14-21 - Recursion must be achieved through tail-calls only + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}]; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}]; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_type.ligo" ; "main" ] ; [%expect {| ligo: error - in file "error_type.ligo", line 3, characters 6-9 - 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 + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_1.mligo" ; "main" ] ; [%expect {| ligo: error - in file "error_typer_1.mligo", line 3, characters 4-7 - Constant declaration 'foo' - Bad types: expected string got int + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_2.mligo" ; "main" ] ; [%expect {| ligo: error - in file "error_typer_2.mligo", line 3, characters 4-7 - Constant declaration 'foo' - Bad types: - expected (type_operator: list(string)) - got (type_operator: option(int)) + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_3.mligo" ; "main" ] ; [%expect {| ligo: error - in file "error_typer_3.mligo", line 3, characters 4-7 - Constant declaration 'foo' - Bad types: - expected ( int * string * sum[false -> unit , true -> unit] ) - got ( int * string ) + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_4.mligo" ; "main" ] ; [%expect {| ligo: error - in file "error_typer_4.mligo", line 4, characters 4-7 - 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]] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_5.mligo" ; "main" ] ; [%expect {| 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]] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_6.mligo" ; "main" ] ; [%expect {| ligo: error - in file "error_typer_6.mligo", line 1, characters 4-7 - Constant declaration 'foo' - Bad types: - expected (type_operator: Map (int,string)) - got (type_operator: Map (int,sum[false -> unit , true -> unit])) + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_typer_7.mligo" ; "main" ] ; [%expect {| ligo: error - in file "error_typer_7.mligo", line 4, characters 4-7 - Constant declaration 'foo' - Bad types: - expected record[a -> int , b -> string] - got record[a -> int , b -> string , c -> sum[false -> unit , true -> unit]] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |} ] ; + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |} ] ; run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/id.mligo" ; "main" ] ; [%expect {| ligo: error - in file "id.mligo", line 28, characters 4-7 - 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] + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] (* This test is here to ensure compatibility with comparable pairs introduced in carthage @@ -222,48 +222,48 @@ let%expect_test _ = run_ligo_bad [ "interpret" ; "Set.literal [ (1,2,3) ; (2,3,4) ]" ; "--syntax=cameligo" ] ; [%expect {| ligo: error - pair does not have a comparable structure. (hint: use (a,(b,c)) instead of (a,b,c)) + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/failwith_wrong_type.ligo" ; "main" ] ; [%expect {| ligo: error - in file "failwith_wrong_type.ligo", line 2, characters 6-9 - Constant declaration 'bad' - Expected arguments with one of the following combinations of type: - (string) or (nat) or (int) - but got (type_operator: list(int)) + 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] let%expect_test _ = run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/compare_sum_types.ligo" ; "main" ] ; [%expect {| ligo: error - in file "compare_sum_types.ligo", line 3, characters 9-13 - Constant declaration 'main' - Those two types are not comparable: - - sum[Bar -> unit , Foo -> unit] - - sum[Bar -> unit , Foo -> unit] + in file "compare_sum_types.ligo", line 3, characters 9-13 + Constant declaration 'main' + Those two types are not comparable: + - sum[Bar -> unit , Foo -> unit] + - sum[Bar -> unit , Foo -> 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 - * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new - * Check the changelog by running 'ligo changelog' |}] \ No newline at end of file + * Visit our documentation: https://ligolang.org/docs/intro/introduction + * Ask a question on our Discord: https://discord.gg/9rhYaEt + * Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new + * Check the changelog by running 'ligo changelog' |}] \ No newline at end of file diff --git a/src/passes/09-typing/08-typer-common/errors.ml b/src/passes/09-typing/08-typer-common/errors.ml index 8a88e9b54..d8a5b10e9 100644 --- a/src/passes/09-typing/08-typer-common/errors.ml +++ b/src/passes/09-typing/08-typer-common/errors.ml @@ -257,10 +257,10 @@ let rec error_ppformat : display_format:string display_format -> Format.fprintf f "%a" (error_ppformat ~display_format) err - | `Typer_constant_declaration_tracer (name,_ae,_,err) -> + | `Typer_constant_declaration_tracer (name,ae,_,err) -> Format.fprintf f "@[%a@ Constant declaration '%a'@ %a@]" - Location.pp name.location + Location.pp ae.location Ast_core.PP.expression_variable name (error_ppformat ~display_format) err | `Typer_match_error (expected,actual,loc) -> From ec2c1571aff98decdc3d1a80d0b5487d4ea6e176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= Date: Fri, 3 Jul 2020 12:46:52 +0200 Subject: [PATCH 2/2] CLI: --output option for compile-contract --- src/bin/cli.ml | 14 +++++++++--- src/bin/cli_helpers.ml | 36 +++++++++++++++++------------- src/bin/cli_helpers.mli | 4 ++-- src/bin/expect_tests/help_tests.ml | 4 ++++ 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/bin/cli.ml b/src/bin/cli.ml index 62bb17c79..8ffb538f5 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -124,6 +124,14 @@ let display_format = human_readable info +let output_file = + let open Arg in + let info = + let docv = "OUTPUT_FILE" in + let doc = "$(docv) if used, prints the output into the specified file instead of stdout" in + info ~docv ~doc ["output" ; "output-file"] in + value @@ opt (some string) None info + let michelson_code_format = let open Arg in let info = @@ -150,15 +158,15 @@ module Decompile = Ligo.Decompile module Run = Ligo.Run.Of_michelson let compile_file = - let f source_file entry_point syntax display_format disable_typecheck michelson_format = - return_result ~display_format (Tezos_utils.Michelson.michelson_format michelson_format) @@ + let f source_file entry_point syntax display_format disable_typecheck michelson_format output_file = + return_result ~output_file ~display_format (Tezos_utils.Michelson.michelson_format michelson_format) @@ let%bind typed,_ = Compile.Utils.type_file source_file syntax (Contract entry_point) in let%bind mini_c = Compile.Of_typed.compile typed in let%bind michelson = Compile.Of_mini_c.aggregate_and_compile_contract mini_c entry_point in Compile.Of_michelson.build_contract ~disable_typecheck michelson in let term = - Term.(const f $ source_file 0 $ entry_point 1 $ syntax $ display_format $ disable_michelson_typechecking $ michelson_code_format) in + Term.(const f $ source_file 0 $ entry_point 1 $ syntax $ display_format $ disable_michelson_typechecking $ michelson_code_format $ output_file) in let cmdname = "compile-contract" in let doc = "Subcommand: Compile a contract." in (Term.ret term , Term.info ~doc cmdname) diff --git a/src/bin/cli_helpers.ml b/src/bin/cli_helpers.ml index 46a948220..1b6ded91e 100644 --- a/src/bin/cli_helpers.ml +++ b/src/bin/cli_helpers.ml @@ -4,21 +4,25 @@ open Main.Display let return_good v = `Ok v let return_bad v = `Error (false, Format.asprintf "@[error@ %s@]" v) -let toplevel : display_format:ex_display_format -> displayable -> ('value, Main_errors.Types.all) result -> unit Term.ret = - fun ~display_format disp value -> - let (Ex_display_format t) = display_format in - let as_str : string = - match t with - | Human_readable -> convert ~display_format:t disp ; - | Dev -> convert ~display_format:t disp ; - | Json -> Yojson.to_string @@ convert ~display_format:t disp - in - match value with - | Ok _ -> return_good @@ - Format.fprintf Format.std_formatter "%s\n" as_str - | Error _ -> return_bad as_str +let toplevel : ?output_file:string option -> display_format:ex_display_format -> displayable -> ('value, Main_errors.Types.all) result -> unit Term.ret = + fun ?(output_file=None) ~display_format disp value -> + let (Ex_display_format t) = display_format in + let as_str : string = + match t with + | Human_readable -> convert ~display_format:t disp ; + | Dev -> convert ~display_format:t disp ; + | Json -> Yojson.to_string @@ convert ~display_format:t disp + in + match value with + | Ok _ -> + let fmt = match output_file with + | Some file_path -> Format.formatter_of_out_channel @@ open_out file_path + | None -> Format.std_formatter + in + return_good @@ Format.fprintf fmt "%s\n" as_str + | Error _ -> return_bad as_str -let return_result : display_format:ex_display_format -> 'value format -> ('value, Main_errors.Types.all) result -> unit Term.ret = - fun ~display_format value_format value -> +let return_result : ?output_file:string option -> display_format:ex_display_format -> 'value format -> ('value, Main_errors.Types.all) result -> unit Term.ret = + fun ?(output_file=None) ~display_format value_format value -> let format = bind_format value_format Main.Formatter.error_format in - toplevel ~display_format (Displayable {value ; format}) value \ No newline at end of file + toplevel ~output_file ~display_format (Displayable {value ; format}) value \ No newline at end of file diff --git a/src/bin/cli_helpers.mli b/src/bin/cli_helpers.mli index a863f45a9..5dcb5966e 100644 --- a/src/bin/cli_helpers.mli +++ b/src/bin/cli_helpers.mli @@ -1,5 +1,5 @@ open Cmdliner open Display -val toplevel : display_format:ex_display_format -> displayable -> ('value, Main_errors.Types.all) result -> unit Term.ret -val return_result : display_format:ex_display_format -> 'value format -> ('value, Main_errors.Types.all) result -> unit Term.ret \ No newline at end of file +val toplevel : ?output_file:string option -> display_format:ex_display_format -> displayable -> ('value, Main_errors.Types.all) result -> unit Term.ret +val return_result : ?output_file:string option -> display_format:ex_display_format -> 'value format -> ('value, Main_errors.Types.all) result -> unit Term.ret \ No newline at end of file diff --git a/src/bin/expect_tests/help_tests.ml b/src/bin/expect_tests/help_tests.ml index abb06515d..6dcbb08e9 100644 --- a/src/bin/expect_tests/help_tests.ml +++ b/src/bin/expect_tests/help_tests.ml @@ -246,6 +246,10 @@ let%expect_test _ = compile-contract for the resulting Michelson. Available formats are 'text' (default), 'json' and 'hex'. + --output-file=OUTPUT_FILE, --output=OUTPUT_FILE + OUTPUT_FILE if used, prints the output into the specified file + instead of stdout + -s SYNTAX, --syntax=SYNTAX (absent=auto) SYNTAX is the syntax that will be used. Currently supported syntaxes are "pascaligo", "cameligo" and "reasonligo". By default,