Skip to content
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

An option to silence behaviour-related warnings #8985

Closed
elbrujohalcon opened this issue Oct 24, 2024 · 1 comment · Fixed by #9020
Closed

An option to silence behaviour-related warnings #8985

elbrujohalcon opened this issue Oct 24, 2024 · 1 comment · Fixed by #9020
Assignees
Labels
enhancement team:VM Assigned to OTP team VM

Comments

@elbrujohalcon
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I want to be able to compile a module like the following one with no warnings:

-module(amazing).
-behaviour(gen_server).

Currently, if I try to compile it, I get…

   ┌─ amazing.erl:
   │
 2-behaviour gen_server.
   │   ╰── Warning: undefined callback function handle_call/3 (behaviour 'gen_server')

   ┌─ amazing.erl:
   │
 2-behaviour gen_server.
   │   ╰── Warning: undefined callback function handle_cast/2 (behaviour 'gen_server')

   ┌─ amazing.erl:
   │
 2-behaviour gen_server.
   │   ╰── Warning: undefined callback function init/1 (behaviour 'gen_server')

Which is expected and fine, but in the same way that we have options to disable other warnings (e.g. nowarn_unused_function, nowarn_keywords, nowarn_update_literal, etc.), I would like to have an option to avoid warnings like the ones above.

Describe the solution you'd like
I would like the addition of the following compiler options:

  • nowarn_conflicting_behaviours
  • nowarn_undefined_behaviour_func
  • nowarn_undefined_behaviour
  • nowarn_undefined_behaviour_callbacks
  • nowarn_ill_defined_behaviour_callbacks
  • nowarn_ill_defined_optional_callbacks
  • nowarn_behaviour_info
  • nowarn_redefine_optional_callback
  • nowarn_undefined_callback

Describe alternatives you've considered
I tried adding -compile([no_lint]). to my module, but the warnings were emitted anyway.

Additional context
This is the source of the necessity: inaka/elvis_core#367 (comment)

@rickard-green rickard-green added the team:VM Assigned to OTP team VM label Oct 28, 2024
@jhogberg jhogberg assigned jhogberg and bjorng and unassigned jhogberg Oct 28, 2024
bjorng added a commit to bjorng/otp that referenced this issue Nov 5, 2024
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
@bjorng
Copy link
Contributor

bjorng commented Nov 5, 2024

I've added the six first of the suggested options in the linked pull request. The last three refers to compiler errors. This will be included in Erlang/OTP 28.

@bjorng bjorng closed this as completed in 0f24dee Nov 11, 2024
bjorng added a commit that referenced this issue Nov 11, 2024
…H-8985/OTP-19334

Add options for silencing warnings for behaviours
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants