Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FunctionClauseError) no function clause matching in :lists.mapfoldl/3 #9390

Closed
futpib opened this issue Oct 9, 2019 · 1 comment
Closed

Comments

@futpib
Copy link

futpib commented Oct 9, 2019

Environment

  • Elixir & Erlang/OTP versions (elixir --version): Elixir 1.9.1 (compiled with Erlang/OTP 22)
  • Operating system: Arch Linux

Current behavior

Running this:

iex <<__EOF__
defmodule Foo do
  def bar() do
    super = 1
    super
  end
end
__EOF__

Gives an error that looks like something went wrong inside the compiler:

** (FunctionClauseError) no function clause matching in :lists.mapfoldl/3    
    
    The following arguments were given to :lists.mapfoldl/3:
    
        # 1
        #Function<4.86030924/2 in :elixir_erl_pass.translate_args/2>
    
        # 2
        {:elixir_erl, :match, nil, false, %{}, %{}, [], %{}, false}
    
        # 3
        nil
    
    (stdlib) lists.erl:1353: :lists.mapfoldl/3

This code does compile on an older Elixir 1.8.2 (compiled with Erlang/OTP 21) without errors:

docker run --rm -i elixir:1.8.2 iex <<__EOF__   
defmodule Foo do
  def bar() do
    super = 1
    super
  end
end
__EOF__
{:module, Foo,
 <<70, 79, 82, 49, 0, 0, 4, 16, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 121,
   0, 0, 0, 13, 10, 69, 108, 105, 120, 105, 114, 46, 70, 111, 111, 8, 95, 95,
   105, 110, 102, 111, 95, 95, 7, 99, 111, ...>>, {:bar, 0}}

Expected behavior

Either this code compiles without errors (as it does on an older Elixir 1.8.2) or a readable compilation error is raised.

@devonestes
Copy link
Contributor

For a little more information, this appears to be an issue with super (probably in the compilation of overridable functions).

Erlang/OTP 21 [erts-10.3.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

Interactive Elixir (1.9.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> defmodule Foo do
...(1)> def bar() do
...(1)> super = 1
...(1)> end
...(1)> end
warning: variable "super" is unused (if the variable is not meant to be used, prefix it with an underscore)
  iex:3: Foo.bar/0

** (FunctionClauseError) no function clause matching in :lists.mapfoldl/3

    The following arguments were given to :lists.mapfoldl/3:

        # 1
        #Function<4.91218841/2 in :elixir_erl_pass.translate_args/2>

        # 2
        {:elixir_erl, :match, nil, false, %{}, %{}, [], %{}, false}

        # 3
        nil

    (stdlib) lists.erl:1353: :lists.mapfoldl/3
iex(1)> defmodule Foo do
...(1)> def bar() do
...(1)> supe = 1
...(1)> end
...(1)> end
warning: variable "supe" is unused (if the variable is not meant to be used, prefix it with an underscore)
  iex:3: Foo.bar/0

{:module, Foo,
 <<70, 79, 82, 49, 0, 0, 4, 36, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 121,
   0, 0, 0, 13, 10, 69, 108, 105, 120, 105, 114, 46, 70, 111, 111, 8, 95, 95,
   105, 110, 102, 111, 95, 95, 7, 99, 111, ...>>, {:bar, 0}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants