Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/spitfire.ex
Original file line number Diff line number Diff line change
Expand Up @@ -964,16 +964,21 @@ defmodule Spitfire do
defp invalid_assoc_call_meta?([_entry | meta]), do: invalid_assoc_call_meta?(meta)

defp invalid_assoc_key_in_map?({name, meta, args}) when is_atom(name) and is_list(meta) and is_list(args) do
arity = length(args)
case args do
[_, _ | _] ->
arity = length(args)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need arity here to pass to Macro.operator? and Macro.special_form?, but we calculate it only if we know it's more than one.


arity > 1 and
not Macro.operator?(name, arity) and
not Macro.special_form?(name, arity) and
invalid_assoc_call_meta?(meta)
not Macro.operator?(name, arity) and
not Macro.special_form?(name, arity) and
invalid_assoc_call_meta?(meta)

_ ->
false
end
end

defp invalid_assoc_key_in_map?({{:., _, [_lhs, _rhs]}, meta, args}) when is_list(meta) and is_list(args) do
length(args) > 1 and invalid_assoc_call_meta?(meta)
match?([_, _ | _], args) and invalid_assoc_call_meta?(meta)
end

defp invalid_assoc_key_in_map?({{name, meta, args}, _value}) when is_atom(name) and is_list(meta) and is_list(args) do
Expand Down Expand Up @@ -3196,7 +3201,7 @@ defmodule Spitfire do
{Enum.reverse(pairs), parser}
end

if length(pairs) == 2 do
if match?([_, _], pairs) do
tuple = encode_literal(parser, pairs |> List.wrap() |> List.to_tuple(), orig_meta)
parser = Map.put(parser, :nesting, old_nesting)
{tuple, parser}
Expand Down Expand Up @@ -3418,7 +3423,7 @@ defmodule Spitfire do

true ->
meta =
if identifier == :op_identifier && length(args) == 1 do
if identifier == :op_identifier && match?([_], args) do
[{:ambiguous_op, nil} | meta]
else
meta
Expand Down
Loading