chrisdel101

chrisdel101

After reading Dialyzer: suppress warning on a specific function, I think I know what I need but I don’t know where to put it.

I get a warning that is just wrong. It’s on code that runs and is often accessed, i.e. a major piece of the codebase. I have this warning in a few other places too where it should not be, and nothing I do gets rid if of it.

The pattern can never match the type.

Pattern:
{:error, _error}

Type:
{:ok, <<_::296>> | map()} | {:error, map(), number()}

I think I can use this to silence it, but where does it go?
@dialyzer {:Wno_match, handle_event/3} Should be maybe @dialyzer {:Wno_match, handle_event: 3}

I put it at the top of the module and I get the error: undefined variable "handle_event" invalid value for @dialyzer attribute: {:Wno_match, [handle_event: 3]} I guess I’m using to wrong also, hence the invalid value, but the docs are quite dense.

This is just the default LiveView handle_event.

PS: this the demo line for how to use this, but it makes no sense to me.

defmodule Myapp.Repo do
  use Ecto.Repo, otp_app: :myapp
  @dialyzer {:nowarn_function, rollback: 1}
end

Let’s start with where in the file this goes. Then we’ll handle the invalid value issue which has sprung up as I posted this.

Showing Posts 1 to 3

chrisdel101

chrisdel101 OP

I got it to work. The @dializer macro (it is a marco right?) goes at the top the module in question. Then you must put in the correct erlang disable warning option.

I had difficulty understanding the erlang docs, but the info was there the entire time. The warning options are these. I needed no_match


warn_option() =
    error_handling | no_behaviours | no_contracts | no_fail_call |
    no_fun_app | no_improper_lists | no_match | no_missing_calls |
    no_opaque | no_return | no_undefined_callbacks |
    no_underspecs | no_unknown | no_unused | underspecs |
    unknown | unmatched_returns | overspecs | specdiffs |
    extra_return | no_extra_return | missing_return |
    no_missing_return

So I put this at the top of my file and the warnings are now ignored.

defmodule MyApp.UserLive.Index do
  @dialyzer {:nowarn_function, handle_event: 3}
sabiwara

sabiwara

Elixir Core Team

It is actually a module attribute, not a macro :slight_smile:
Like macros, they are also compile-time.

chrisdel101

chrisdel101 OP

So I was correct in thinking I that was probably going to be wrong there :slight_smile:.
I still don’t really get all the terminology around here, but thanks for the link. It’ll help in fixing that.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews