Project

General

Profile

Actions

Bug #12793

closed

Warning.warn with non-string object

Added by znz (Kazuhiro NISHIYAMA) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-09-27 trunk 56273) [x86_64-linux]
[ruby-core:77430]

Description

Warning.warn with non-string argument causes SEGV.
For example, Warning.warn nil.

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Open to Closed

Applied in changeset r56274.


error.c: check argument of Warning.warn

Updated by znz (Kazuhiro NISHIYAMA) over 7 years ago

Kernel#warn accepts nil and 1, but Warning.warn raises TypeError.
Is this difference expected?

% ruby -ve 'warn nil; Warning.warn nil'
ruby 2.4.0dev (2016-09-28 trunk 56281) [x86_64-linux]

-e:1:in `warn': wrong argument type nil (expected String) (TypeError)
        from -e:1:in `<main>'
% ruby -ve 'warn 1; Warning.warn 1'
ruby 2.4.0dev (2016-09-28 trunk 56281) [x86_64-linux]
1
-e:1:in `warn': wrong argument type Integer (expected String) (TypeError)
        from -e:1:in `<main>'

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

While Kernel#warn should be generous since it is a public API,
Warning.warn is a method called by the internal and should be strict.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0