-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.2.7.3] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.19.3 (compiled with Erlang/OTP 27)
Operating system
any
Current behavior
https://hexdocs.pm/elixir/1.19.3/operators.html lists :: as having lower precedence than =>, yet
Code.string_to_quoted!("%{a :: b => c}")
{:%{}, [line: 1],
[
{{:"::", [line: 1], [{:a, [line: 1], nil}, {:b, [line: 1], nil}]},
{:c, [line: 1], nil}}
]}
Code.string_to_quoted!("%{a => b :: c}")
{:%{}, [line: 1],
[
{{:a, [line: 1], nil},
{:"::", [line: 1], [{:b, [line: 1], nil}, {:c, [line: 1], nil}]}}
]}
proves that it has higher precedence
Similarly, other operators listed below => all have higher precedence
iex(16)> Code.string_to_quoted!("%{a | b => c}")
{:%{}, [line: 1],
[
{:|, [line: 1],
[{:a, [line: 1], nil}, [{{:b, [line: 1], nil}, {:c, [line: 1], nil}}]]}
]}
iex(17)> Code.string_to_quoted!("%{a when b => c}")
{:%{}, [line: 1],
[
{{:when, [line: 1], [{:a, [line: 1], nil}, {:b, [line: 1], nil}]},
{:c, [line: 1], nil}}
]}
iex(18)> Code.string_to_quoted!("%{a <- b => c}")
{:%{}, [line: 1],
[
{{:<-, [line: 1], [{:a, [line: 1], nil}, {:b, [line: 1], nil}]},
{:c, [line: 1], nil}}
]}
iex(19)> Code.string_to_quoted!("%{a \\\\ b => c}")
{:%{}, [line: 1],
[
{{:\\, [line: 1], [{:a, [line: 1], nil}, {:b, [line: 1], nil}]},
{:c, [line: 1], nil}}
]}
iex(23)> Code.string_to_quoted!("%{a => b | c}")
{:%{}, [line: 1],
[
{{:a, [line: 1], nil},
{:|, [line: 1], [{:b, [line: 1], nil}, {:c, [line: 1], nil}]}}
]}
iex(24)> Code.string_to_quoted!("%{a => b when c}")
{:%{}, [line: 1],
[
{{:a, [line: 1], nil},
{:when, [line: 1], [{:b, [line: 1], nil}, {:c, [line: 1], nil}]}}
]}
iex(25)> Code.string_to_quoted!("%{a => b <- c}")
{:%{}, [line: 1],
[
{{:a, [line: 1], nil},
{:<-, [line: 1], [{:b, [line: 1], nil}, {:c, [line: 1], nil}]}}
]}
iex(26)> Code.string_to_quoted!("%{a => b \\\\ c}")
{:%{}, [line: 1],
[
{{:a, [line: 1], nil},
{:\\, [line: 1], [{:b, [line: 1], nil}, {:c, [line: 1], nil}]}}
]}
with only exception being %{a | b => c} which is map update syntax
Expected behavior
Precedence table corrected
Metadata
Metadata
Assignees
Labels
No labels