-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Make verify trim printing more readable (also fix the colours) #60350
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
base: master
Are you sure you want to change the base?
Conversation
topolarity
left a comment
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.
Looks like a solid improvement to me. Thanks @gbaraldi !
Compiler/src/verifytrim.jl
Outdated
| if newstmt.head ∈ (:quote, :inert) | ||
| return newstmt | ||
| # Check if a union is small with concrete types (same logic as code_warntype's is_expected_union) | ||
| function is_expected_union(@nospecialize(u::Union)) |
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.
Maybe instead of duplicating, we should move these into the Compiler printing utilities and have InteractiveUtils pull them in from there?
Compiler/src/verifytrim.jl
Outdated
| end | ||
|
|
||
| # Print with light_black if stable, normal otherwise | ||
| function print_styled(io::IO, @nospecialize(x), stable::Bool) |
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.
| function print_styled(io::IO, @nospecialize(x), stable::Bool) | |
| function print_nontype(io::IO, @nospecialize(x), stable::Bool) |
Not a great name, but better than print_styled and printstyled floating around in the same function
| # Convert Core.Argument to slot name symbol if available | ||
| function argument_name(codeinfo::CodeInfo, arg::Core.Argument) | ||
| slotnames = codeinfo.slotnames | ||
| if slotnames !== nothing && arg.n <= length(slotnames) |
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.
The IR verifier seems to suggest that codeinfo.slotnames is always populated and the right length - Is that not true?
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.
Where do you see that?
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.
Most uses I see do check it.
Compiler/src/verifytrim.jl
Outdated
| if codeinfo.slotnames !== nothing | ||
| io = IOContext(io, :SOURCE_SLOTNAMES => sourceinfo_slotnames(codeinfo)) | ||
| # Colors for matching parentheses at different nesting levels | ||
| const PAREN_COLORS = (:blue, :yellow, :magenta, :cyan, :green) |
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'm really not a fan of multi-colored parentheses personally
They really overload the maximum number of visual items I can track at a time. Do you think they're very helpful?
Compiler/src/verifytrim.jl
Outdated
| if warn | ||
| printstyled(io, "Verifier warning #", no, ": "; color=Base.warn_color(), bold=true) | ||
| else | ||
| printstyled(io, "Verifier error #", no, ": "; color=Base.error_color(), bold=true) | ||
| end |
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.
| if warn | |
| printstyled(io, "Verifier warning #", no, ": "; color=Base.warn_color(), bold=true) | |
| else | |
| printstyled(io, "Verifier error #", no, ": "; color=Base.error_color(), bold=true) | |
| end | |
| printstyled(io, "Problem #", no, ": "; color=Base.warn_color(), bold=true) |
The index is shared but these are counted separately, so changing between "error" / "warning" seems a bit confusing to me
9c34e95 to
eca85d5
Compare
pr:

master:

Inspired by @jakobnissen's blog https://viralinstruction.com/posts/aoc2025/
Written with AI help