Skip to content

Commit 18bcef3

Browse files
author
José Valim
committed
Fix a bug when inspecting records nested in tuples
1 parent 115fd99 commit 18bcef3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/elixir/lib/binary/inspect.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ defimpl Binary.Inspect, for: Tuple do
335335
list = tuple_to_list(record)
336336
[name|tail] = list
337337

338-
if (fields = record_fields(name)) && (length(fields) == size(record) - 1) do
338+
if is_atom(name) && (fields = record_fields(name)) && (length(fields) == size(record) - 1) do
339339
if Enum.first(tail) == :__exception__ do
340340
record_join(name, tl(fields), tl(tail), opts)
341341
else

lib/elixir/test/elixir/binary/inspect_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ defmodule Binary.Inspect.TupleTest do
136136
assert inspect(:something.new) == ":something[a: nil, b: nil]"
137137
end
138138

139+
defrecord Rec, value: 1
140+
141+
test :two_items_record do
142+
assert inspect({ Rec[value: 1], 1 }) == "{Binary.Inspect.TupleTest.Rec[value: 1],1}"
143+
end
144+
139145
test :empty do
140146
assert inspect({}) == "{}"
141147
end

0 commit comments

Comments
 (0)