Project

General

Profile

Bug #14262

ArgumentError (negative level (-1)) when `warn "test message", uplevel: -2`

Added by znz (Kazuhiro NISHIYAMA) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2017-12-30 trunk 61515) [x86_64-darwin16]
[ruby-core:84568]

Description

When uplevel: -2, error message says negative level (-1).
When uplevel: -1, no exception occur.
What is expected behavior?

% irb -r irb/completion --simple-prompt
>> warn("test", uplevel: -1)
(irb):1: warning: test
=> nil
>> warn("test", uplevel: -2)
Traceback (most recent call last):
        3: from bin/irb:11:in `<main>'
        2: from (irb):2
        1: from (irb):2:in `warn'
ArgumentError (negative level (-1))
>> warn("test", uplevel: 0)
(irb):3: warning: test
=> nil
>> warn("test", uplevel: 1)

Related issues

Related to Ruby master - Feature #12882: Add caller/file/line information to internal Kernel#warn callsClosedActions

Associated revisions

Revision fa2e4a20
Added by nobu (Nobuyoshi Nakada) over 1 year ago

error.c: negative uplevel

  • error.c (rb_warn_m): negative uplevel is not allowed. [ruby-core:84568] [Bug #14262]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 61525
Added by nobu (Nobuyoshi Nakada) over 1 year ago

error.c: negative uplevel

  • error.c (rb_warn_m): negative uplevel is not allowed. [ruby-core:84568] [Bug #14262]

Revision 61525
Added by nobu (Nobuyoshi Nakada) over 1 year ago

error.c: negative uplevel

  • error.c (rb_warn_m): negative uplevel is not allowed. [ruby-core:84568] [Bug #14262]

Revision 487efc80
Added by nobu (Nobuyoshi Nakada) over 1 year ago

test_exception.rb: more assertions

[ruby-core:84568] [Bug #14262]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 61526
Added by nobu (Nobuyoshi Nakada) over 1 year ago

test_exception.rb: more assertions

[ruby-core:84568] [Bug #14262]

Revision 61526
Added by nobu (Nobuyoshi Nakada) over 1 year ago

test_exception.rb: more assertions

[ruby-core:84568] [Bug #14262]

Revision 905189b2
Added by nagachika (Tomoyuki Chikanaga) about 1 year ago

merge revision(s) 61525,61527,63062,63650: [Backport #14846]

    error.c: negative uplevel

    * error.c (rb_warn_m): negative uplevel is not allowed.
      [ruby-core:84568] [Bug #14262]

    error.c: limit depth

    * error.c (rb_warn_m): limit backtrace depth to reduce objects to
      be created but not used.

    error.c: prepend "warning: " always

    * error.c (rb_warn_m): prepend the string "warning: " if uplevel
      keyword is given, even if caller file and line information are
      not available.

    Fix condition in Kernel#warn when using uplevel

    * It causes SEGV on `warn("foo", uplevel: 100)`.
    * Found in a ruby/spec added by @andrykonchin in
      https://github.com/ruby/spec/pull/605

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@63819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63819
Added by nagachika (Tomoyuki Chikanaga) about 1 year ago

merge revision(s) 61525,61527,63062,63650: [Backport #14846]

error.c: negative uplevel

* error.c (rb_warn_m): negative uplevel is not allowed.
  [ruby-core:84568] [Bug #14262]

error.c: limit depth

* error.c (rb_warn_m): limit backtrace depth to reduce objects to
  be created but not used.

error.c: prepend "warning: " always

* error.c (rb_warn_m): prepend the string "warning: " if uplevel
  keyword is given, even if caller file and line information are
  not available.

Fix condition in Kernel#warn when using uplevel

* It causes SEGV on `warn("foo", uplevel: 100)`.
* Found in a ruby/spec added by @andrykonchin in
  https://github.com/ruby/spec/pull/605

History

#1

Updated by znz (Kazuhiro NISHIYAMA) over 1 year ago

  • Related to Feature #12882: Add caller/file/line information to internal Kernel#warn calls added
#2

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r61525.


error.c: negative uplevel

  • error.c (rb_warn_m): negative uplevel is not allowed. [ruby-core:84568] [Bug #14262]

Also available in: Atom PDF