Skip to content

Improve error messages for invalid expression in match #5649

@grych

Description

@grych

Environment

  • Elixir & Erlang versions (elixir -v):
    Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
    Elixir 1.4.0
  • Operating system:
    OS X El Capitan

Current behavior

iex(1)> f = &List.first/1
&List.first/1
iex(3)> case f do
...(3)>   &List.first/1 -> 11
...(3)> end
** (CompileError) iex:4: invalid expression in match
    (stdlib) lists.erl:1354: :lists.mapfoldl/3

however the other way works as expected:

iex(3)> case &List.first/1 do
...(3)> f -> 22
...(3)> end
22

Expected behavior

As a first-class citizen, function should work in case as it works in other pattern matching cases.

iex(3)> case f do
...(3)>   &List.first/1 -> 11
...(3)> end
11


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