Skip to content

Conversation

@shreyas-omkar
Copy link

Fixes #53907

The subtraction A[k][1]-length(vdots) could underflow if A[k][1]
was a UInt (e.g., UInt(0)), leading to a massive string
allocation. This commit casts the values to Int before the
subtraction to prevent the underflow.

@shreyas-omkar shreyas-omkar force-pushed the fix-arrayshow-unsigned-v2 branch from d8b0986 to da08f2f Compare October 21, 2025 15:09
@oscardssmith oscardssmith added the needs tests Unit tests are required for this change label Oct 21, 2025
w = A[k][1] + A[k][2]
if k % M == m
l = repeat(" ", max(0, A[k][1]-length(vdots)))
l = repeat(" ", max(0, Int(A[k][1])-length(vdots)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
l = repeat(" ", max(0, Int(A[k][1])-length(vdots)))
l = repeat(" ", max(0, Signed(A[k][1])-length(vdots)))

r = k == length(A) && !pad_right ?
"" :
repeat(" ", max(0, w-length(vdots)-length(l)))
repeat(" ", max(0, Int(w)-length(vdots)-length(l)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
repeat(" ", max(0, Int(w)-length(vdots)-length(l)))
repeat(" ", max(0, Signed(w)-length(vdots)-length(l)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs tests Unit tests are required for this change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Displaying array with unsigned indices throws

4 participants