-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Inspect ill-formed structs as maps #14718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,7 +396,7 @@ defmodule Inspect.Algebra do | |
def to_doc_with_opts(term, opts) | ||
|
||
def to_doc_with_opts(%_{} = struct, %Inspect.Opts{inspect_fun: fun} = opts) do | ||
if opts.structs do | ||
if opts.structs and Inspect.Map.valid_struct?(struct) do | ||
|
||
try do | ||
fun.(struct, opts) | ||
rescue | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,14 +200,6 @@ defmodule RangeTest do | |
end | ||
|
||
describe "old ranges" do | ||
test "inspect" do | ||
asc = %{__struct__: Range, first: 1, last: 3} | ||
desc = %{__struct__: Range, first: 3, last: 1} | ||
|
||
assert inspect(asc) == "1..3" | ||
assert inspect(desc) == "3..1//-1" | ||
end | ||
Comment on lines
-203
to
-209
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These will be rendered as maps, which I think is acceptable now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is! |
||
|
||
test "enum" do | ||
asc = %{__struct__: Range, first: 1, last: 3} | ||
desc = %{__struct__: Range, first: 3, last: 1} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually do we still need this if it is handled upstream in
Inspect.Algebra
?Perhaps I could just call
module.__info__(:struct)
directly, I wasn't sure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with cab02a1, let me know if that's OK.