kidp330
No behaviour warnings when running script with receive block
I came across this issue when using a behaviour from a dependency and did not see any warnings when I implemented a callback with the wrong number of arguments. I used mix run --no-mix-exs script.exs. Reproducible on 1.15.7 but works as expected on 1.13.4.
Here’s an MRE:
defmodule MyBehaviour do
@callback my_fun(arg :: any) :: any
end
defmodule MyModule do
@behaviour MyBehaviour
@impl true
def my_fub(arg) do
arg
end
end
IO.puts("Hello world")
Output using 1.13.4 and 1.15.7:
root@5da670a83b2e:/workspace/my_project# mix run --no-mix-exs script.exs
warning: got "@impl true" for function my_fub/1 but no behaviour specifies such callback. The known callbacks are:
* MyBehaviour.my_fun/1 (function)
script.exs:9: MyModule (module)
warning: function my_fun/1 required by behaviour MyBehaviour is not implemented (in module MyModule)
script.exs:5: MyModule (module)
Hello world
root@5da670a83b2e:/workspace/my_project#
With receive block:
defmodule MyBehaviour do
@callback my_fun(arg :: any) :: any
end
defmodule MyModule do
@behaviour MyBehaviour
@impl true
def my_fub(arg) do
arg
end
end
IO.puts("Hello world")
receive do
:done -> MyModule.my_fub("Hello again")
end
Output using both versions:
root@5da670a83b2e:/workspace/my_project# asdf global elixir 1.13
root@5da670a83b2e:/workspace/my_project# mix run --no-mix-exs script.exs
warning: got "@impl true" for function my_fub/1 but no behaviour specifies such callback. The known callbacks are:
* MyBehaviour.my_fun/1 (function)
script.exs:9: MyModule (module)
warning: function my_fun/1 required by behaviour MyBehaviour is not implemented (in module MyModule)
script.exs:5: MyModule (module)
Hello world
^C
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
(l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
a
root@5da670a83b2e:/workspace/my_project# asdf global elixir 1.15.7
root@5da670a83b2e:/workspace/my_project# mix run --no-mix-exs script.exs
Hello world
I’d be grateful for any help, cheers
Popular in Questions
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work.
Or rather, not char, but a substr...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Other popular topics
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
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
can someone please explain to me how Enum.reduce works with maps
New
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
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
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New







