summaryrefslogtreecommitdiff
path: root/warning.rb
diff options
context:
space:
mode:
Diffstat (limited to 'warning.rb')
-rw-r--r--warning.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/warning.rb b/warning.rb
index 4e34c63833..625dd9506b 100644
--- a/warning.rb
+++ b/warning.rb
@@ -40,14 +40,20 @@ module Kernel
# baz.rb:6: warning: invalid call to foo
#
# If <code>category</code> keyword argument is given, passes the category
- # to <code>Warning.warn</code>. The category given must be be one of the
+ # to <code>Warning.warn</code>. The category given must be one of the
# following categories:
#
# :deprecated :: Used for warning for deprecated functionality that may
# be removed in the future.
# :experimental :: Used for experimental features that may change in
# future releases.
+ # :performance :: Used for warning about APIs or pattern that have
+ # negative performance impact
def warn(*msgs, uplevel: nil, category: nil)
- Primitive.rb_warn_m(msgs, uplevel, category)
+ if Primitive.cexpr!("NIL_P(category)")
+ Primitive.rb_warn_m(msgs, uplevel, nil)
+ elsif Warning[category = Primitive.cexpr!("rb_to_symbol_type(category)")]
+ Primitive.rb_warn_m(msgs, uplevel, category)
+ end
end
end