-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options for silencing warnings for behaviours #9020
Add options for silencing warnings for behaviours #9020
Conversation
CT Test Results 3 files 417 suites 1h 12m 31s ⏱️ Results for commit b38327e. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
This commit adds the following compiler options for suppressing warnings having to do with behaviours: * nowarn_conflicting_behaviours * nowarn_undefined_behaviour_func * nowarn_undefined_behaviour * nowarn_undefined_behaviour_callbacks * nowarn_ill_defined_behaviour_callbacks * nowarn_ill_defined_optional_callbacks Closes erlang#8985
d0a1d6e
to
0f24dee
Compare
Should there be an option for completely skipping any behaviour-related checks? In most cases those checks can be performed by xref or dialyzer without actually loading the module into the VM. Offloading the check to those tools (in projects that use them) could simplify compilation significantly and increase scalability of the compiler by removing compile-time dependencies between modules. |
Yes, that makes sense. I've added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good PR. I just added some suggestions in case they help
add_behaviour_warning(Anno, Warning, St) when is_tuple(Warning) -> | ||
Tag = element(1, Warning), | ||
case is_warn_enabled(Tag, St) of | ||
true -> | ||
add_warning(Anno, Warning, St); | ||
false -> | ||
St | ||
end. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_behaviour_warning(Anno, Warning, St) when is_tuple(Warning) -> | |
Tag = element(1, Warning), | |
case is_warn_enabled(Tag, St) of | |
true -> | |
add_warning(Anno, Warning, St); | |
false -> | |
St | |
end. | |
add_behaviour_warning(Anno, Warning, St) when is_tuple(Warning) -> | |
Tag = element(1, Warning), | |
Command = fun () -> add_warning(Anno, Warning, St) end), | |
if_warn_enabled(Tag, St, Command. | |
if_warn_enabled(Tag, St, Command) -> | |
case is_warn_enabled(Tag, St) of | |
true -> | |
Command(); | |
false -> | |
St | |
end. |
This is a suggestion to a common pattern in this PR.
Take it if you find it useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I will save it for a clean-up of erl_lint
that I am planning to do.
check_behaviour(St) -> | ||
case is_warn_enabled(behaviours, St) of | ||
true -> | ||
behaviour_check(St#lint.behaviour, St); | ||
false -> | ||
St | ||
end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check_behaviour(St) -> | |
case is_warn_enabled(behaviours, St) of | |
true -> | |
behaviour_check(St#lint.behaviour, St); | |
false -> | |
St | |
end. | |
check_behaviour(St) -> | |
Command = fun () -> behaviour_check(St#lint.behaviour, St) end, | |
if_warn_enabled(behaviours, St, Command). |
Take this is you like, must be applied with the other suggestion below
This commit adds the following compiler options for suppressing warnings having to do with behaviours:
Closes #8985