diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cf97f5..ed83675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed ### Removed ### Fixed +- Warning about unused include when there is no include. ## [7.1.0] ### Added diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 2184662..ac0ef42 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -3207,9 +3207,14 @@ when_warning(Warn, Do) -> %% Warnings (Unused includes) potential_unused_include(Ann, SrcFile) -> - case aeso_syntax:get_ann(file, Ann, no_file) of - no_file -> ok; - File -> ets_insert(warnings, {unused_include, File, SrcFile}) + IsIncluded = aeso_syntax:get_ann(include_type, Ann, none) =/= none, + case IsIncluded of + false -> ok; + true -> + case aeso_syntax:get_ann(file, Ann, no_file) of + no_file -> ok; + File -> ets_insert(warnings, {unused_include, File, SrcFile}) + end end. used_include(Ann) -> diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index e070fd7..9eb002d 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -69,6 +69,7 @@ simple_compile_test_() -> [ {"Testing warning messages", fun() -> #{ warnings := Warnings } = compile("warnings", [warn_all]), + #{ warnings := [] } = compile("warning_unused_include_no_include", [warn_all]), check_warnings(warnings(), Warnings) end} ] ++ []. diff --git a/test/contracts/warning_unused_include_no_include.aes b/test/contracts/warning_unused_include_no_include.aes new file mode 100644 index 0000000..edf2fd2 --- /dev/null +++ b/test/contracts/warning_unused_include_no_include.aes @@ -0,0 +1,5 @@ +namespace N = + function nconst() = 1 + +main contract C = + entrypoint f() = N.nconst()