Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel#warn keyword handling differs from CRuby #5873

Closed
jeremyevans opened this issue Sep 12, 2019 · 3 comments
Closed

Kernel#warn keyword handling differs from CRuby #5873

jeremyevans opened this issue Sep 12, 2019 · 3 comments

Comments

@jeremyevans
Copy link
Contributor

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.
@headius
Copy link
Member

headius commented Sep 23, 2019

I guess the first case is not outputting anything? It doesn't show up in your expected behavior.

@jeremyevans
Copy link
Contributor Author

Correct, warn({}) isn't treated as option hash by JRuby (outputs {}), unlike with CRuby (outputs nothing).

@kares
Copy link
Member

kares commented Sep 24, 2019

actually ended up looking at this myself (while missing some kwargs warnings) ... patch of its way

kares added a commit to kares/jruby that referenced this issue Sep 24, 2019
mostly handle warn({}) & warn('foo', {}) as if Hash wasn't passed

resolves jrubyGH-5873
@kares kares closed this as completed in e6b1bd3 Sep 24, 2019
@kares kares added this to the JRuby 9.2.9.0 milestone Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants