-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Description
Elixir and Erlang/OTP versions
Erlang/OTP 28 [erts-16.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
Elixir 1.20.0-rc.0 (0f9d919) (compiled with Erlang/OTP 28)
Operating system
macOS
Current behavior
Compile the following module:
defmodule Test do
def default_format(data) do
case String.Chars.impl_for(data) do
nil -> inspect(data)
mod -> mod.to_string(data)
end
end
endThe warning that I'm getting is:
warning: nil.to_string/1 is undefined (module nil is not available or is yet to be defined)
│
5 │ mod -> mod.to_string(data)
│ ~
│
└─ lib/test.ex:5:18: Test.default_format/1
Expected behavior
I was expecting the handling of nil on line 4 to make it so that mod was non-nil on line 5. Adding a guard on line 5 removes the warning as you'd expect.
Metadata
Metadata
Assignees
Labels
No labels