Skip to content

Commit

Permalink
Fix deprecation warning on SimpleXML example (#139)
Browse files Browse the repository at this point in the history
> warning: returning a two-element tuple {acc, context} in pre_traverse/post_traverse
 > is deprecated, please return {rest, acc, context} instead
 >   SimpleXML.node__31/6
 >   SimpleXML.parse__0/6
 >   SimpleXML.parse/2
 >   examples/simple_xml.exs:50: anonymous fn/1 in :elixir_compiler_2.__FILE__/1
 >   (elixir 1.17.0-rc.1) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
 >   (elixir 1.17.0-rc.1) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
  • Loading branch information
Gazler authored Jun 27, 2024
1 parent 9cb1f6c commit 03610c5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/simple_xml.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ defmodule SimpleXML do
|> concat(closing_tag)
|> post_traverse(:match_and_emit_tag)

defp match_and_emit_tag(_rest, [tag, [tag, text]], context, _line, _offset),
do: {[{String.to_atom(tag), [], text}], context}
defp match_and_emit_tag(rest, [tag, [tag, text]], context, _line, _offset),
do: {rest, [{String.to_atom(tag), [], text}], context}

defp match_and_emit_tag(_rest, [tag, [tag | nodes]], context, _line, _offset),
do: {[{String.to_atom(tag), [], nodes}], context}
defp match_and_emit_tag(rest, [tag, [tag | nodes]], context, _line, _offset),
do: {rest, [{String.to_atom(tag), [], nodes}], context}

defp match_and_emit_tag(_rest, [opening, [closing | _]], _context, _line, _offset),
do: {:error, "closing tag #{inspect(closing)} did not match opening tag #{inspect(opening)}"}
Expand Down

0 comments on commit 03610c5

Please sign in to comment.