`list -- list` causes unexpected result

I can reproduce the result like following. I wondered why the third one doesn’t result with []

iex(1)> x = [
20190122090654, 20190122090702, 20190122090705, 20190122090717, 20190124020608,
20190204062925, 20190204062926, 20190204063000, 20190204063001, 20190206064600,
20190314000000, 20190315000000, 20190705045039, 20190930010000, 20190930010001,
20190930010002, 20190930010003, 20190930010004, 20190930010005, 20201006015136,
20201009011409
]
iex(2)>  x == x
true
iex(3)> x -- x
[20190314000000, 20190930010005, 20201009011409]

Erlang: 21.2
Elixir 1.8.1

[note]
BTW, one day I’ve realized that executing mix ecto.migrations results below.
It was due to the result of list -- list issue, by the way.

  Status    Migration ID    Migration Name
--------------------------------------------------
<snip>
  up        20190930010000  create_meal_reports
  up        20190930010000  ** FILE NOT FOUND **
  up        20190930010001  create_meal_report_menu
  up        20190930010002  create_meal_report_claps
  up        20190930010003  create_meal_report_comments
  up        20190930010004  create_indexes_meal
  up        20190930010005  create_unique_indexes_meal
  up        20190930010005  ** FILE NOT FOUND **
  up        20201006015136  modify_qestion_type
  up        20201009011409  modify_meal_reports
  up        20201009011409  ** FILE NOT FOUND **

For me it looks different:

$ iex
Erlang/OTP 23 [erts-11.1.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.11.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> x = [                                      
...(1)> 20190122090654, 20190122090702, 20190122090705, 20190122090717, 20190124020608,
...(1)> 20190204062925, 20190204062926, 20190204063000, 20190204063001, 20190206064600,
...(1)> 20190314000000, 20190315000000, 20190705045039, 20190930010000, 20190930010001,
...(1)> 20190930010002, 20190930010003, 20190930010004, 20190930010005, 20201006015136,
...(1)> 20201009011409
...(1)> ]
[20190122090654, 20190122090702, 20190122090705, 20190122090717, 20190124020608,
 20190204062925, 20190204062926, 20190204063000, 20190204063001, 20190206064600,
 20190314000000, 20190315000000, 20190705045039, 20190930010000, 20190930010001,
 20190930010002, 20190930010003, 20190930010004, 20190930010005, 20201006015136,
 20201009011409]
iex(2)> x == x
true
iex(3)> x -- x
[]

Looks like you need to make an update. Unfortunately I did not found mention of fix for such bug in changelog and therefore I don’t know which versions are affected.

Hmm, now I’ve confirmed that it works as expected, say x -- x is [], in Elixir 1.11.2(Erlang 23.1.2)

Because I’ve also failed to find any description about the bug in changelog, I worry that it might occur in the future versions.

Based on Elixir's source code I guess that was an Erlang bug:

Possibly related: https://bugs.erlang.org/browse/ERL-986

2 Likes

Thank you. That’s it! As long as Erlang is older than the version(22.0.5 / 21.3.8.5), the issue still occurs even in the latest Elixir.

[NG]

  • Erlang 21.2.4
    • Elixir 1.8.1
    • Elixir 1.11.2

[OK]

  • Erlang 22.1

    • Elixir 1.8.1
    • Elixir 1.11.2
  • Erlang 23.1

    • Elixir 1.11.2
1 Like

And this folks is why property tests are great! :smiley: