pelemay icon indicating copy to clipboard operation
pelemay copied to clipboard

For Numexy.add

Open zacky1972 opened this issue 4 years ago • 1 comments

Describe the bug When applying Pelemay to Numexy.add, an error occurs.

The code is as follows: https://github.com/zeam-vm/numexy/blob/zacky1972_develop/lib/numexy.ex#L43

To Reproduce Steps to reproduce the behavior:

  1. Use Pelemay in the source code as follows: https://github.com/zeam-vm/numexy/blob/zacky1972_develop/lib/numexy.ex#L43

  2. Run in the command 'mix test'

  3. See error:

$ mix test
==> pelemay
Compiling 8 files (.ex)
Generated pelemay app
==> numexy
Compiling 2 files (.ex)

== Compilation error in file lib/numexy.ex ==
** (FunctionClauseError) no function clause matching in SumMag.optimize_func/2    
    
    The following arguments were given to SumMag.optimize_func/2:
    
        # 1
        {:defp, [line: 44], [{:enum_add_sub, [line: 44], [{:list, [line: 44], nil}, {:s, [line: 44], nil}]}, [do: {:|>, [line: 45], [{:list, [line: 45], nil}, {{:., [line: 45], [{:__aliases__, [line: 45], [:Enum]}, :map]}, [line: 45], [{:&, [line: 45], [{:+, [line: 45], [{:&, [line: 45], [1]}, {:s, [line: 45], nil}]}]}]}]}]]}
    
        # 2
        #Function<0.131710887/1 in Pelemay."MACRO-defpelemay"/2>
    
    Attempted function clauses (showing 1 out of 1):
    
        defp optimize_func({:def, meta, [arg_info, exprs]}, optimizer)
    
    lib/sum_mag.ex:257: SumMag.optimize_func/2
    (elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
    lib/sum_mag.ex:253: SumMag.map/2
    expanding macro: Pelemay.defpelemay/1
    lib/numexy.ex:43: Numexy (module)

Expected behavior mix test should be done successfully.

Screenshots None.

Desktop (please complete the following information):

  • Pelemay Version: 0.0.2
  • Elixir & Erlang/OTP versions (elixir --version):
$ elixir -v
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 (OS name & version, and uname -a):

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 versions (clang -v):
$ clang -v
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

Current Pelemay may support not to use it in defp nor to use second parameter in NIFs.

zacky1972 avatar Sep 22 '19 09:09 zacky1972

Pelemay transform Enum.map to a native function with one argument. So, it is no works when variables exist in anonymous function.

hisaway avatar Sep 27 '19 08:09 hisaway