Skip to content

Commit

Permalink
remove List.last
Browse files Browse the repository at this point in the history
  • Loading branch information
dkuku committed May 29, 2024
1 parent 8bf3e6c commit 3ad6b09
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/elixir/lib/macro.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ defmodule Macro do
quote do
unquote(acc_var) = []
unquote(dbg_boolean_tree(ast, acc_var, result_var))
{:logic_op, Enum.reverse(unquote(acc_var))}
{:logic_op, Enum.reverse(unquote(acc_var)), unquote(result_var)}
end
end

Expand All @@ -2610,7 +2610,7 @@ defmodule Macro do
quote do
unquote(acc_var) = []
unquote(dbg_block(ast, acc_var, result_var))
{:block, Enum.reverse(unquote(acc_var))}
{:block, Enum.reverse(unquote(acc_var)), unquote(result_var)}
end
end

Expand Down Expand Up @@ -2712,7 +2712,7 @@ defmodule Macro do
end
end)

{:__block__, meta, modified_clauses ++ [result_var]}
{:__block__, meta, modified_clauses}
end

# Made public to be called from Macro.dbg/3, so that we generate as little code
Expand Down Expand Up @@ -2752,28 +2752,28 @@ defmodule Macro do
{[first_formatted | rest_formatted], result}
end

defp dbg_format_ast_to_debug({:logic_op, components}, options) do
{_ast, final_value} = List.last(components)

defp dbg_format_ast_to_debug({:logic_op, components, value}, options) do
formatted =
Enum.map(components, fn {ast, value} ->
[dbg_format_ast(to_string_with_colors(ast, options)), " ", inspect(value, options), ?\n]
end)

{formatted, final_value}
{formatted, value}
end

defp dbg_format_ast_to_debug({:block, components}, options) do
{_ast, final_value} = List.last(components)

defp dbg_format_ast_to_debug({:block, components, value}, options) do
formatted =
[dbg_maybe_underline("Code block", options), ":\n(\n"] ++
[
dbg_maybe_underline("Code block", options),
":\n(\n",
Enum.map(components, fn {ast, value} ->
[" ", dbg_format_ast_with_value(ast, value, options)]
end) ++
[?), ?\n]
end),
?),
?\n
]

{formatted, final_value}
{formatted, value}
end

defp dbg_format_ast_to_debug({:case, ast, expr_value, clause_index, value}, options) do
Expand Down

0 comments on commit 3ad6b09

Please sign in to comment.