From a037466f2d8fe5391d162fa9093ab5fc654f93df Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Mon, 27 Nov 2023 11:35:15 +0300 Subject: [PATCH] Do not show warning for types used in records --- src/aeso_ast_infer_types.erl | 4 ++-- test/aeso_compiler_tests.erl | 1 + test/contracts/warning_used_record_typedef.aes | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 test/contracts/warning_used_record_typedef.aes diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index ae75468..2af3b62 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -924,14 +924,14 @@ infer(Contracts, Options) -> {Env1, Decls} = infer1(Env, Contracts1, [], Options), when_warning(warn_unused_functions, fun() -> destroy_and_report_unused_functions() end), when_option(warn_error, fun() -> destroy_and_report_warnings_as_type_errors() end), - WarningsUnsorted = lists:map(fun mk_warning/1, ets_tab2list(warnings)), - Warnings = aeso_warnings:sort_warnings(WarningsUnsorted), {Env2, DeclsFolded, DeclsUnfolded} = case proplists:get_value(dont_unfold, Options, false) of true -> {Env1, Decls, Decls}; false -> E = on_scopes(Env1, fun(Scope) -> unfold_record_types(Env1, Scope) end), {E, Decls, unfold_record_types(E, Decls)} end, + WarningsUnsorted = lists:map(fun mk_warning/1, ets_tab2list(warnings)), + Warnings = aeso_warnings:sort_warnings(WarningsUnsorted), case proplists:get_value(return_env, Options, false) of false -> {DeclsFolded, DeclsUnfolded, Warnings}; true -> {Env2, DeclsFolded, DeclsUnfolded, Warnings} diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index b0f2008..483531f 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -70,6 +70,7 @@ simple_compile_test_() -> fun() -> #{ warnings := Warnings } = compile("warnings", [warn_all]), #{ warnings := [] } = compile("warning_unused_include_no_include", [warn_all]), + #{ warnings := [] } = compile("warning_used_record_typedef", [warn_all]), check_warnings(warnings(), Warnings) end} ] ++ []. diff --git a/test/contracts/warning_used_record_typedef.aes b/test/contracts/warning_used_record_typedef.aes new file mode 100644 index 0000000..537b19a --- /dev/null +++ b/test/contracts/warning_used_record_typedef.aes @@ -0,0 +1,5 @@ +contract Test = + type option_int = option(int) + record option_point = {x: int, y: option_int} + + entrypoint test_option_record(a: option_point) = a