Mark only included files as potentially unused (#442)
* Mark only included files as potentially unused * Update CHANGELOG * Add test
This commit is contained in:
parent
311bf49505
commit
99bb3fe1fb
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Changed
|
### Changed
|
||||||
### Removed
|
### Removed
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Warning about unused include when there is no include.
|
||||||
|
|
||||||
## [7.1.0]
|
## [7.1.0]
|
||||||
### Added
|
### Added
|
||||||
|
@ -3207,9 +3207,14 @@ when_warning(Warn, Do) ->
|
|||||||
%% Warnings (Unused includes)
|
%% Warnings (Unused includes)
|
||||||
|
|
||||||
potential_unused_include(Ann, SrcFile) ->
|
potential_unused_include(Ann, SrcFile) ->
|
||||||
case aeso_syntax:get_ann(file, Ann, no_file) of
|
IsIncluded = aeso_syntax:get_ann(include_type, Ann, none) =/= none,
|
||||||
no_file -> ok;
|
case IsIncluded of
|
||||||
File -> ets_insert(warnings, {unused_include, File, SrcFile})
|
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.
|
end.
|
||||||
|
|
||||||
used_include(Ann) ->
|
used_include(Ann) ->
|
||||||
|
@ -69,6 +69,7 @@ simple_compile_test_() ->
|
|||||||
[ {"Testing warning messages",
|
[ {"Testing warning messages",
|
||||||
fun() ->
|
fun() ->
|
||||||
#{ warnings := Warnings } = compile("warnings", [warn_all]),
|
#{ warnings := Warnings } = compile("warnings", [warn_all]),
|
||||||
|
#{ warnings := [] } = compile("warning_unused_include_no_include", [warn_all]),
|
||||||
check_warnings(warnings(), Warnings)
|
check_warnings(warnings(), Warnings)
|
||||||
end} ] ++
|
end} ] ++
|
||||||
[].
|
[].
|
||||||
|
5
test/contracts/warning_unused_include_no_include.aes
Normal file
5
test/contracts/warning_unused_include_no_include.aes
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
namespace N =
|
||||||
|
function nconst() = 1
|
||||||
|
|
||||||
|
main contract C =
|
||||||
|
entrypoint f() = N.nconst()
|
Loading…
x
Reference in New Issue
Block a user