Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObj
argMessagesLen--;

IRubyObject[] ret = ArgsUtil.extractKeywordArgs(context, (RubyHash) opts, "uplevel", "category");
if (ret[0] != null) {
if (ret[0] != null && !ret[0].isNil()) {
explicitUplevel = true;
uplevel = toInt(context, ret[0]);
if (uplevel < 0) throw argumentError(context, "negative level (" + uplevel + ")");
Expand Down
6 changes: 6 additions & 0 deletions spec/ruby/core/kernel/warn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
ruby_exe(file, options: "-rrubygems", args: "2>&1").should == "#{file}:2: warning: warn-require-warning\n"
end

it "doesn't show the caller when the uplevel is `nil`" do
w = KernelSpecs::WarnInNestedCall.new

-> { w.f4("foo", nil) }.should output(nil, "foo\n")
end

guard -> { Kernel.instance_method(:tap).source_location } do
it "skips <internal: core library methods defined in Ruby" do
file, line = Kernel.instance_method(:tap).source_location
Expand Down
Loading