Skip to content

fix show of self referential arrays #58863

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

adienes
Copy link
Member

@adienes adienes commented Jul 1, 2025

see the tests for some MWE this fixes

closes #47280

@adienes adienes added arrays [a, r, r, a, y, s] bugfix This change fixes an existing bug labels Jul 1, 2025
@adienes adienes marked this pull request as draft July 1, 2025 16:53
@adienes adienes added the display and printing Aesthetics and correctness of printed representations of objects. label Jul 1, 2025
@adienes adienes changed the title fix reflexivity and stackoverflow of == on self referential arrays, as well as show fix show of self referential arrays Jul 1, 2025
@adienes adienes marked this pull request as ready for review July 1, 2025 17:25
@adienes adienes requested a review from jishnub July 8, 2025 12:35
@adienes
Copy link
Member Author

adienes commented Aug 14, 2025

look ok?

  • this only touches display code
  • it turns a stackoverflow into correct behavior + adds test

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

I thought this was usually only handled at the start of applicable show methods, not each element (part 1 but not part 2 of this PR)?

@adienes
Copy link
Member Author

adienes commented Aug 15, 2025

ok, I just check it in function show(io::IO, X::AbstractArray) now

note that the alignment is a bit funky for showing in REPL

julia> m = Any[1 2; 3 4];

julia> m[1] = m
2×2 Matrix{Any}:
  2×2 Matrix{Any}:#= circular reference @-1 =#  2
 3                              4

but fixing the alignment seems quite involved and ideally I'd leave that to a separate PR

edit: looks like that issue is #40547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] bugfix This change fixes an existing bug display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with displaying a matrix with circular reference
2 participants