File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -488,9 +488,12 @@ function show(io::IO, X::AbstractArray)
488
488
if ! implicit
489
489
io = IOContext (io, :typeinfo => eltype (X))
490
490
end
491
- isempty (X) ?
492
- _show_empty (io, X) :
493
- _show_nonempty (io, X, prefix)
491
+ if isempty (X)
492
+ return _show_empty (io, X)
493
+ end
494
+ show_circular (io, X) && return
495
+ recur_io = IOContext (io, :SHOWN_SET => X)
496
+ _show_nonempty (recur_io, X, prefix)
494
497
end
495
498
496
499
# ## 0-dimensional arrays (#31481)
Original file line number Diff line number Diff line change @@ -2316,3 +2316,21 @@ end
2316
2316
v2 = view (A, Base. IdentityUnitRange (1 : length (A)))
2317
2317
@test sum (x for x in v2) == sum (A)
2318
2318
end
2319
+
2320
+ @testset " self referential" begin
2321
+ v = Any[1 ,2 ,3 ]
2322
+ v[1 ] = v
2323
+ io = IOBuffer ()
2324
+ show (io, v)
2325
+ @test String (take! (io)) == " Any[Any[#= circular reference @-1 =#], 2, 3]"
2326
+
2327
+ m1 = Any[1 2 ; 3 4 ]
2328
+ m1[1 ] = m1
2329
+ show (io, m1)
2330
+ @test String (take! (io)) == " Any[#= circular reference @-1 =# 2; 3 4]"
2331
+
2332
+ m2 = Any[1 ; 2 ;; 3 ; 4 ;;; 5 ; 6 ;; 7 ; 8 ]
2333
+ m2[1 ] = m2
2334
+ show (io, m2)
2335
+ @test String (take! (io)) == " Any[#= circular reference @-1 =# 3; 2 4;;; 5 7; 6 8]"
2336
+ end
You can’t perform that action at this time.
0 commit comments