Repository navigation
Kernel#warn: route through Warning.warn with category filtering - #462
Merged
Merged
Conversation
Kernel#warn wrote its arguments straight to $stderr and ignored the category:
and uplevel: keywords. It now builds one message — each argument on its own line,
a newline appended only when the argument does not already end with one — and
routes it through Warning.warn(message, category:), so a program that overrides
Warning.warn (or reads the category) sees it, as in MRI.
- A String category is converted to a Symbol; any other non-nil, non-Symbol
value raises TypeError ("no implicit conversion of X into Symbol").
- A category whose warnings are disabled (Warning[category] is false) drops the
message without calling Warning.warn; an unknown category raises the
ArgumentError Warning.[] raises.
- The uplevel: keyword is validated (a negative value raises ArgumentError
"negative level (n)", a non-Integer a TypeError) but not acted on, as rbgo has
no caller line to prepend.
- No message does nothing.
Verified against ruby 4.0.6. Full package coverage stays at 100.0%. Zero-
regression rubyspec sweep; core/kernel/warn_spec 3 -> 8 and core/warning/warn_spec
3 -> 4. (The residual examples need parser-emitted warnings to route through
Warning.warn, Warning.warn arity introspection, or the -w default the harness does
not set — separate concerns.)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kernel#warnwrote its arguments straight to$stderrand ignored thecategory:anduplevel:keywords. It now builds one message — each argument onits own line, a newline appended only when the argument does not already end with
one — and routes it through
Warning.warn(message, category:), so a program thatoverrides
Warning.warn(or reads the category) sees it, as in MRI.raises
TypeError(no implicit conversion of X into Symbol).Warning[category]is false) drops themessage without calling
Warning.warn; an unknown category raises theArgumentErrorWarning.[]raises.uplevel:keyword is validated (a negative value raisesArgumentError "negative level (n)", a non-Integer aTypeError) but not acted on, as rbgohas no caller line to prepend.
Verified against ruby 4.0.6. Full package coverage stays at 100.0%.
Zero-regression rubyspec sweep;
core/kernel/warn_spec3 → 8 andcore/warning/warn_spec3 → 4. (The residual examples need parser-emittedwarnings to route through
Warning.warn,Warning.warnarity introspection, orthe
-wdefault the harness does not set — separate concerns.)🤖 Generated with Claude Code