Skip to content

Possible incorrect warning on dynamic module calls #14043

Closed as not planned
Closed as not planned
@wkirschbaum

Description

@wkirschbaum

Elixir and Erlang/OTP versions

Elixir 1.18.0-dev (4328b09) (compiled with Erlang/OTP 27)

Operating system

Linux

Current behavior

With the following code snippet:

defmodule Foo do
  def something(input) do
    case module(input) do
      :error -> ""
      module -> module.zar()
    end
  end

  def zar() do
  end

  defp module(input) do
    if input == "bar" do
      :error
    else
      Foo
    end
  end
end

I get the following warning:

    warning: :error.zar/0 is undefined (module :error is not available or is yet to be defined)
    │
  5 │       module -> module.zar()
    │                        ~
    │
    └─ foo.exs:5:24: Foo.something/1

Expected behavior

The handles the :error case, so the warning is a false positive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions