pelemay
pelemay copied to clipboard
Build failed in the case that there is a defpelemay macro for each module.
Describe the bug Build failed in the case that there is a defpelemay for each module.
To Reproduce Steps to reproduce the behavior:
-
mix new test
- Define Test in
lib/test.ex
as follows:
defmodule Test do
alias Test.Test1
alias Test.Test2
@moduledoc """
Documentation for Test.
"""
def do_test() do
1..1000
|> Enum.to_list()
|> Test1.do_test()
|> Test2.do_test()
end
end
- Define Test.Test1 in
lib/test/test1.ex
as follows:
defmodule Test.Test1 do
require Pelemay
import Pelemay
defpelemay do
def do_test(list) do
list |> Enum.map(& &1 * 2)
end
end
end
- Define Test.Test2 in
lib/test/test2.ex
as follows:
defmodule Test.Test2 do
require Pelemay
import Pelemay
defpelemay do
def do_test(list) do
list |> Enum.map(& &1 + 1)
end
end
end
-
mix compile
will be failed in the following errors:
$ mix compile
Compiling 3 files (.ex)
== Compilation error in file lib/test/test2.ex ==
** (ArgumentError) argument error
(stdlib) :ets.new(:nif_func, [:set, :public, :named_table])
lib/pelemay/db.ex:10: Pelemay.Db.init/0
expanding macro: Pelemay.defpelemay/1
lib/test/test2.ex:5: Test.Test2 (module)
Expected behavior
The compile mix compile
become successful, and iex -S mix
and type following command will works:
$ iex -S mix
Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Interactive Elixir (1.9.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Test.do_test
[3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43,
45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83,
85, 87, 89, 91, 93, 95, 97, 99, 101, ...]
iex(2)>
Screenshots None.
Desktop (please complete the following information):
- Pelemay version: 0.0.2
- Elixir & Erlang/OTP versions (
elixir --version
):
$ elixir --version
Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Elixir 1.9.1 (compiled with Erlang/OTP 22)
- OS:
macOS Mojave 10.14.6
$ uname -a
Darwin *** 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
- Clang Version:
$ clang --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Additional context
The compile will works the following steps:
- Make test2.ex inactive
-
mix compile
- Make test2.ex active
-
mix compile
Perhaps, it doesn't work in the case of two or more compilation of defpelemay concurrently.