SirWerto

SirWerto

Warning on :gen_statem behaviours

Good morning,
I’m using the :gen_statem erlang behaviour for modeling a process and the compiler is throwing me some warnings about bad implementations behaviours

This is the module definition

defmodule Collector.Plubio do
  @behaviour :gen_statem

I am doing the calls like that

  @spec state?() :: {:ok, :waiting | :collecting} | {:error, :timeout}
  def state?() do
    try do
      case :gen_statem.call(Collector.Plubio, :current_state, 5000) do
	:waiting -> {:ok, :waiting}
	:collecting -> {:ok, :collecting}
      end
    rescue
      RuntimeError -> {:error, :timeout}
    end
  end

And the :gen_statem.state_name/3 are like this

  @impl true
  def waiting({:call, from}, :current_state, state) do
    {:next_state, :waiting, state, {:reply, from, :waiting}}
  end

But the compiler still showing me these warnings

warning: got "@impl true" for function waiting/3 but this behaviour does not specify such callback. The known callbacks are:

  * :gen_statem.callback_mode/0 (function)
  * :gen_statem.code_change/4 (function)
  * :gen_statem.format_status/2 (function)
  * :gen_statem.handle_event/4 (function)
  * :gen_statem.init/1 (function)
  * :gen_statem.state_name/3 (function)
  * :gen_statem.terminate/3 (function)

It is my first time calling directly and erlang behaviour so probably I am forgetting something, does someone knows how to fix that?
Thank you so much:)

Marked As Solved

kokolegorille

kokolegorille

The error is about…

… maybe remove this?

Also Liked

josevalim

josevalim

Creator of Elixir

To add to @kokolegorille’s reply, :gen_statem only has a handful of static callbacks. The other callbacks are dynamic, based on your code, and those do not get a @impl true.

Where Next?

Popular in Questions Top

gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

We're in Beta

About us Mission Statement