Skip to content

Wrong undefined function warning #14058

Closed
@dominicletz

Description

@dominicletz

Elixir and Erlang/OTP versions

elixir 1.18.0-rc.0
erlang 26.2.5.3

Operating system

Linux

Current behavior

Compiling:

defmodule TypeBug do
  def file_monitor_backened?() do
    case :os.type() do
      {:unix, :darwin} -> :fsevents
      {:unix, :linux} -> :inotifywait
      {:win32, :nt} -> :inotifywait_win32
      _ -> nil
    end
    |> case do
      nil -> false
      backend -> backend.find_executable() != false
    end
  end
end

produces this warning:

   warning: nil.find_executable/0 is undefined (module nil is not available or is yet to be defined)
    │
 14 │         backend.find_executable() != false~
    │
    └─ lib/type_bug.ex:11:26: TypeBug.has_file_monitor_backened?/0

Expected behavior

There should be no warning, since the nil case is handled already.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions