Skip to content

Commit

Permalink
Disable unused type warnings for type used inside of records (#492)
Browse files Browse the repository at this point in the history
* Do not show warning for types used in records

* Exclude .vscode in .gitignore

* Update CHANGELOG.md
  • Loading branch information
ghallak authored Nov 27, 2023
1 parent 03d6dd6 commit cdbd430
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ current_counterexample.eqc
test/contracts/test.aes
__pycache__
.docssite/docs/*.md
.vscode
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
include paths are now always relative to the file containing the `include` statement.
### Removed
### Fixed
- Disable unused type warnings for types used inside of records.

## [7.4.0]
### Changed
Expand Down
4 changes: 2 additions & 2 deletions src/aeso_ast_infer_types.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions test/aeso_compiler_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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} ] ++
[].
Expand Down
5 changes: 5 additions & 0 deletions test/contracts/warning_used_record_typedef.aes
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cdbd430

Please sign in to comment.