elixir-lang / elixir

Elixir is a dynamic, functional language for building scalable and maintainable applications
https://elixir-lang.org/
Apache License 2.0
24.52k stars 3.38k forks source link

Getting new compile error for timex 0.19.2 on Elixir 1.3.0-rc.0 #4759

Closed myronmarston closed 8 years ago

myronmarston commented 8 years ago

Environment

$ elixir --version
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:32:2] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.3.0-rc.0 (7881123)

Ubuntu 12.04.5 LTS (on travis)

Current behavior

I wanted to give Elixir 1.3.0-rc.0 a try and updated the .travis.yml in our main application to see if it could build OK on the new version. The build failed while trying to compile timex 0.19.2:

== Compilation error on file lib/date/date_format.ex ==
** (ArgumentError) defdelegate/2 only accepts function parameters, got: %DateTime{} = date
    (elixir) lib/kernel/utils.ex:55: Kernel.Utils.add_arg/2
    (elixir) lib/kernel/utils.ex:25: Kernel.Utils.defdelegate/2
    lib/date/date_format.ex:22: anonymous fn/3 in :elixir_compiler_24.__MODULE__/1
    (elixir) lib/enum.ex:1557: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/date/date_format.ex:22: (module)
could not compile dependency :timex, "mix compile" failed. You can recompile this dependency with "mix deps.compile timex", update it with "mix deps.update timex" or clean it with "mix deps.clean timex"

It looks like this line is the culprit:

defdelegate format(%DateTime{} = date, format_string), to: Formatter

Expected behavior

I expected our project to compile OK given it compiled OK on Elixir 1.2.5 and I didn't think 1.3.0-rc.0 was meant to have any breaking changes. It also looks like maybe Timex was doing something that was never supported (but didn't fail, either). Should this compile error be a warning instead? If the new compiler error is intentional it would be nice if it was called out in the changelog. The one mention of defdelegate in the changelog doesn't sounds different from this compile error:

[Kernel] Add deprecation for defdelegate list arguments and :append_first option

Regardless, it looks like newer versions of timex do not have this problem so I'll work on upgrading our project to timex 2.

josevalim commented 8 years ago

@myronmarston thank you. I have decided to update the changelog to mention it because such syntax was never officially supported and it gets in the way of some features we have implemented on v1.3 (like defdelegate with default args).