elixir icon indicating copy to clipboard operation
elixir copied to clipboard

There's a compilation error when we define a private macro with a default parameter

Open pedrosnk opened this issue 9 years ago • 2 comments

Environment

  • Elixir master (introduced recently) Erlang 19.2
  • Operating system: OSX

Current behavior

When we define a private macro with default argument it generates an undefined function error

defmodule Foo do
  # this works
  defmacrop my_macro_b(b) do
    IO.inspect b
  end

  # this doesn't
  defmacrop my_macro_a(a \\ nil) do
    IO.inspect a
  end
end

The error

== Compilation error on file lib/foo.ex ==
** (CompileError) lib/foo.ex:19: undefined function MACRO-my_macro_a/2
    (stdlib) lists.erl:1338: :lists.foreach/2
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

It seems like the my_macro_a is defining a function with wrong arity.

thx =D

pedrosnk avatar Jan 24 '17 11:01 pedrosnk

Can you include the code that produces the error? The code in the module Foo you included works fine for me.

ericmj avatar Jan 24 '17 11:01 ericmj

@ericmj it is on master, I will fix it. :)

josevalim avatar Jan 24 '17 11:01 josevalim