Skip to content

Conversation

sabiwara
Copy link
Contributor

Close #14717

Comment on lines -203 to -209
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will be rendered as maps, which I think is acceptable now?
It's been a while since stepped ranges.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is!

for %{field: field} = map <- info,
field != :__exception__,
do: map
if info = Inspect.Map.valid_struct_info(struct) do
Copy link
Contributor Author

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.

Copy link
Contributor Author

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.


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move the function to this module instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed makes sense, I initially thought I'd need it at several places but not anymore 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful! We should probably not backport this one though!

@sabiwara
Copy link
Contributor Author

We should probably not backport this one though!

OK! Any particular concern regarding this?
Since we're still in rc0, it should still leave some room for people to try it out and report potential issues, but it's not really a bug so no rush either. Up to you!

@sabiwara sabiwara merged commit d4ba7ee into elixir-lang:main Aug 23, 2025
13 checks passed
@sabiwara sabiwara deleted the valid-struct-inspect branch August 23, 2025 08:10
@josevalim
Copy link
Member

Oh, sorry, we should totally backport this to v1.19 (i was thinking about backporting to v1.18, which we should not :D).

sabiwara added a commit that referenced this pull request Aug 23, 2025
@sabiwara
Copy link
Contributor Author

i was thinking about backporting to v1.18, which we should not :D

Haha OK. I wouldn't have thought of backporting that far 😄

we should totally backport this to v1.19

Done

@josevalim
Copy link
Member

Yeah, it was my bad. Slow Saturday morning :-)

ggVGc pushed a commit to ggVGc/elixir-literal that referenced this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected behavior of Map.merge(<map set>, ...)
2 participants