Skip to content

Kernel#warn keyword handling differs from CRuby #5873

@jeremyevans

Description

@jeremyevans

Environment

jruby 9.2.8.0 (2.5.3) 2019-08-12 a1ac7ff OpenJDK 64-Bit Server VM 25.222-b10 on 1.8.0_222-b10 +jit [OpenBSD-x86_64]
OpenBSD foo.local 6.5 GENERIC.MP#171 amd64

This is unlikely to be operating system dependent, and does not involve gems or environment variables.

Expected Behavior

$ ruby25 -ve 'warn({}); warn("a", {}); warn(Class.new{def to_s; "foo" end}.new, :uplevel=>0)'
ruby 2.5.6p201 (2019-08-28 revision 67796) [x86_64-openbsd]
a
-e:1: warning: foo

Actual Behavior

$ jruby -ve 'warn({}); warn("a", {}); warn(Class.new{def to_s; "foo" end}.new, :uplevel=>0)'
jruby 9.2.8.0 (2.5.3) 2019-08-12 a1ac7ff OpenJDK 64-Bit Server VM 25.222-b10 on 1.8.0_222-b10 +jit [OpenBSD-x86_64]
{}
-e:1: warning: a
TypeError: no implicit conversion of #<Class:0x17d677df> into String
       + at org/jruby/RubyString.java:1181
  <main> at -e:1

At least three separate issues:

  • warn({}): Single hash argument is not treated as an option hash.
  • warn("a", {}): Empty option hash treated as uplevel 0 instead of no uplevel.
  • warn(Class.new{def to_s; "foo" end}.new, :uplevel=>0): No conversion of object to string using to_s if uplevel is provided.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions