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

Splatted arguments sometimes aren't passed to methods properly. #2926

Closed
chanks opened this issue Feb 7, 2014 · 14 comments · Fixed by #2938
Closed

Splatted arguments sometimes aren't passed to methods properly. #2926

chanks opened this issue Feb 7, 2014 · 14 comments · Fixed by #2938
Labels

Comments

@chanks
Copy link

chanks commented Feb 7, 2014

This is a weird one. The JIT, maybe?

# test.rb
$index = 0

def m(input = 5)
  if input == 5
    puts $index += 1
  else
    raise "Input: #{input.inspect}"
  end
end

value = nil

loop do
  m(*value)
end

Then:

ruby test.rb
...
43304
43305
43306
43307
43308
43309
An exception occurred running test.rb:

    Input: nil (RuntimeError)

Backtrace:

                          Object#m at test.rb:7
          { } in Object#__script__ at test.rb:14
               Kernel(Object)#loop at kernel/common/kernel.rb:460
                 Object#__script__ at test.rb:13
  Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66
  Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:201
           Rubinius::Loader#script at kernel/loader.rb:649
             Rubinius::Loader#main at kernel/loader.rb:831

ruby -v
rubinius 2.2.3 (2.1.0 4792e746 2013-12-29 JI) [x86_64-linux-gnu]
@chanks
Copy link
Author

chanks commented Feb 7, 2014

Just upgraded to 2.2.4, same thing happens.

@yorickpeterse
Copy link
Contributor

This indeed seems to be the JIT. Running the script with the JIT disabled (rbx -Xint script.rb) does not seem to produce the same error.

@dbussink
Copy link
Contributor

dbussink commented Feb 8, 2014

Further simplification:

loop do
  value = nil
  ary = *value
  if ary == [nil]
    raise "error"
  end
end

@dbussink
Copy link
Contributor

dbussink commented Feb 8, 2014

So I've found the issue and it's fairly straightforward. I'd like to offer up pairing on this with someone if they're interested in finding out more about how some of the bits in the JIT work and how this case can be fixed.

@yorickpeterse
Copy link
Contributor

I'd be up for that, and I'm pretty sure others might be too (e.g. @razielgn might be interested as well).

@ileitch
Copy link
Member

ileitch commented Feb 8, 2014

Maybe record a short video like you did once before? I enjoyed watching.

@dbussink
Copy link
Contributor

dbussink commented Feb 9, 2014

@ileitch One thing I thought about is doing a hangout and recording that for posterity so people can view that.

@razielgn
Copy link
Contributor

razielgn commented Feb 9, 2014

An hangout sounds very good to me. We could join live to ask questions if we manage to find a common time/date. :)

@dbussink
Copy link
Contributor

I can do a hangout Tuesday evening CET timezone, how does that sound?

@yorickpeterse
Copy link
Contributor

Fine by me!

@razielgn
Copy link
Contributor

I can make it from 6pm to 8pm.

@dbussink
Copy link
Contributor

How about Tuesday 19:00 CET then? We should get through it pretty quick I think.

@razielgn
Copy link
Contributor

Yeah, sounds good. Thank you. :)

@yorickpeterse
Copy link
Contributor

19:00 is a bit too early for me as that's around the time I hop in a train. I'm perfectly fine with watching the recording though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants