vt-elixir / ja_serializer

JSONAPI.org Serialization in Elixir.
Other
640 stars 148 forks source link

Compilation error when using `length` as attribute in serializer #283

Closed tompesman closed 5 years ago

tompesman commented 6 years ago

For example:

  defmodule ArticleSerializer do
    use JaSerializer
    attributes [:length]
  end

This won't compile:

== Compilation error in file test/ja_serializer/serializer_test.exs ==
** (CompileError) test/ja_serializer/serializer_test.exs:8: imported Kernel.length/1 conflicts with local function
    (elixir) src/elixir_locals.erl:89: :elixir_locals."-ensure_no_import_conflict/3-lc$^0/1-0-"/2
    (elixir) src/elixir_locals.erl:89: anonymous fn/3 in :elixir_locals.ensure_no_import_conflict/3
    test/ja_serializer/serializer_test.exs:4: (module)
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (elixir) lib/code.ex:677: Code.require_file/2
    (elixir) lib/kernel/parallel_compiler.ex:201: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

This happens after updating from 0.12.0 to 0.13.0. Is this expected behaviour?

Cheers, Tom

marpo60 commented 5 years ago

Hi @tompesman I open a PR to fix this.

If you could give it a try and let me know if it fixes your issues it would be great.

Thanks

tompesman commented 5 years ago

Thank you @marpo60 this fixes my issue! 👍