Unary operator and iex

I am having a hard time understanding what’s happening here. Is unary operator applied to the value of last expression in iex? Is this known to be documented anywhere?

Erlang/OTP 24 [RELEASE CANDIDATE 2] [erts-12.0] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Interactive Elixir (1.12.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> x = 1
1
iex(2)> -x
0
iex(3)> -x
-1
iex(4)> -x
-2
iex(5)> -x
-3
iex(6)> -x
-4
iex(7)> -x
-5
iex(8)> x
1
iex(9)> -x
0
iex(10)> -x
-1
iex(11)> -x
-2
iex(12)>

This is a bug related to a recent feature that we added for multi-line operators but it has been fixed and never released. Please try a more recent v1.12 (such as the RC). :slight_smile:

5 Likes

Updated to RC-0, all good now. Thank you! :slight_smile: