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

unexpected kIF_MOD Jruby9k, but not 1.7.x #2936

Closed
DougEverly opened this issue May 13, 2015 · 2 comments
Closed

unexpected kIF_MOD Jruby9k, but not 1.7.x #2936

DougEverly opened this issue May 13, 2015 · 2 comments
Milestone

Comments

@DougEverly
Copy link

Getting SyntaxError: (irb):4: syntax error, unexpected kIF_MOD when assigning hash key the value of an if expression.

Here is the code I am pasting in:

@something = Hash.new

@d = {
  type:  if @something.is_a?(Hash)
           'hash'
         elsif @something.is_a?(Array)
           'array'
         else
           'unknown'
         end,
  foo: "bar"
}

puts @d

** Jruby 1.7.19 **

Code pasted into jruby 1.7.9 rib.

rvm use jruby-1.7.19 do irb
jruby-1.7.19 :001 > @something = Hash.new
 => {}
jruby-1.7.19 :002 >
jruby-1.7.19 :003 >   @d = {
jruby-1.7.19 :004 >       type:  if @something.is_a?(Hash)
jruby-1.7.19 :005?>                'hash'
jruby-1.7.19 :006?>              elsif @something.is_a?(Array)
jruby-1.7.19 :007?>                'array'
jruby-1.7.19 :008?>              else
jruby-1.7.19 :009 >                  'unknown'
jruby-1.7.19 :010?>              end,
jruby-1.7.19 :011 >       foo: "bar"
jruby-1.7.19 :012?>   }
 => {:type=>"hash", :foo=>"bar"}
jruby-1.7.19 :013 >
jruby-1.7.19 :014 >   puts @d
{:type=>"hash", :foo=>"bar"}
 => nil

** jruby-9.0.0.0.pre2 **

Same code pasted into jruby-9.0.0.0.pre2 irb.

rvm use jruby-9.0.0.0.pre2 do irb
jruby-9.0.0.0.pre2 :001 > @something = Hash.new
 => {}
jruby-9.0.0.0.pre2 :002 >
jruby-9.0.0.0.pre2 :003 >   @d = {
jruby-9.0.0.0.pre2 :004 >       type:  if @something.is_a?(Hash)
jruby-9.0.0.0.pre2 :005?>                'hash'
jruby-9.0.0.0.pre2 :006?>              elsif @something.is_a?(Array)
jruby-9.0.0.0.pre2 :007?>                'array'
jruby-9.0.0.0.pre2 :008?>              else
jruby-9.0.0.0.pre2 :009 >                  'unknown'
jruby-9.0.0.0.pre2 :010?>              end,
jruby-9.0.0.0.pre2 :011 >       foo: "bar"
jruby-9.0.0.0.pre2 :012?>   }
SyntaxError: (irb):4: syntax error, unexpected kIF_MOD
  type:  if @something.is_a?(Hash)

    from org/jruby/RubyKernel.java:1005:in `eval'
    from org/jruby/RubyKernel.java:1315:in `loop'
    from org/jruby/RubyKernel.java:1125:in `catch'
    from org/jruby/RubyKernel.java:1125:in `catch'
    from /Users/deverly/.rvm/rubies/jruby-9.0.0.0.pre2/bin/irb:13:in `<top>'
jruby-9.0.0.0.pre2 :013 >
jruby-9.0.0.0.pre2 :014 >   puts @d

 => nil
@MSNexploder
Copy link
Contributor

Works as expected on 9.1.9.0:

irb(main):001:0> @something = Hash.new
=> {}
irb(main):002:0> 
irb(main):003:0*   @d = {
irb(main):004:1*       type:  if @something.is_a?(Hash)
irb(main):005:2>                'hash'
irb(main):006:2>              elsif @something.is_a?(Array)
irb(main):007:2>                'array'
irb(main):008:2>              else
irb(main):009:2*                  'unknown'
irb(main):010:2>              end,
irb(main):011:1*       foo: "bar"
irb(main):012:1>   }
=> {:type=>"hash", :foo=>"bar"}
irb(main):013:0> 
irb(main):014:0*   puts @d
{:type=>"hash", :foo=>"bar"}
=> nil

@headius
Copy link
Member

headius commented May 21, 2017

Thanks for the update!

@headius headius closed this as completed May 21, 2017
@headius headius added this to the JRuby 9.1.9.0 milestone May 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants