Skip to content

Suspicious warning about shadowed vars in case #1524

@alco

Description

@alco
defmodule M do
  def test(x) do
    case x do
      {:file, fid} -> fid

      {:path, _} ->
        fn(fid) ->               # variable fid shadowed in 'fun'
          fid
        end
    end
  end
end

Compiler produces the warning showed in the comment above.

Semantically equivalent Erlang code does not produce a warning:

-module(tst).
-export([test/1]).

test(X) ->
  case X of
    {file, Fid} -> Fid;

    {path, _} ->
      fun(Fid) ->
        Fid
      end
  end.

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