From 86b4c433b964fb6f26e7904aa88fcde09526b92d Mon Sep 17 00:00:00 2001 From: Andreas Lappe Date: Fri, 17 Apr 2020 16:35:51 +0200 Subject: [PATCH] fix: Keep `_` in patterns --- lib/erlex.ex | 2 +- test/literals_pretty_print_test.exs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/erlex.ex b/lib/erlex.ex index a234614..e8a9a16 100644 --- a/lib/erlex.ex +++ b/lib/erlex.ex @@ -572,7 +572,7 @@ defmodule Erlex do end end - defp atomize(<>) when is_number(atom) do + defp atomize(<>) when is_number(atom) and atom != 95 do "#{atom}" end diff --git a/test/literals_pretty_print_test.exs b/test/literals_pretty_print_test.exs index 4f5e827..503b3b2 100644 --- a/test/literals_pretty_print_test.exs +++ b/test/literals_pretty_print_test.exs @@ -131,4 +131,11 @@ defmodule Erlex.Test.LiteralsPretyPrintTest do assert pretty_printed == "<<_ :: 8, _ :: size(1)>>, false" end + + test "keep underscore in pattern" do + input = "{'embed', __@3, __@4}" + pretty_printed = Erlex.pretty_print_type(input) + + assert pretty_printed == "{:embed, _, _}" + end end