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

Incorrect parameters value for procs and methods #2396

Closed
psyho opened this issue Jun 25, 2013 · 5 comments
Closed

Incorrect parameters value for procs and methods #2396

psyho opened this issue Jun 25, 2013 · 5 comments

Comments

@psyho
Copy link

psyho commented Jun 25, 2013

I run into some problems on Rubinius, where it returns different values for parameters than MRI 1.9.3.

For the following program:

class Foo
  def self.bar(*)
  end
end

unnamed_splat_params = Foo.method(:bar).parameters
puts "Wrong parameters for method with unnamed splat #{unnamed_splat_params.inspect}" unless unnamed_splat_params == [[:rest]]

foo = proc{ |*| }

proc_with_splat = foo.parameters
puts "Wrong parameters for proc with unnamed splat #{proc_with_splat.inspect}" unless proc_with_splat == [[:rest]]

class Bar
  def self.baz(*args, &block)
    options = {}
    foo = {}
  end
end

block_with_splat = Bar.method(:baz).parameters
puts "Wrong parameters for method with splat and block #{block_with_splat.inspect}" unless block_with_splat == [[:rest, :args], [:block, :block]]

bar = proc do |*args, &block|
  options = {}
  foo = {}
end

proc_with_block_and_splat = bar.parameters
puts "Wrong parameters for proc with splat and block #{proc_with_block_and_splat.inspect}" unless proc_with_block_and_splat == [[:rest, :args], [:block, :block]]

The output on rbx-head is:

Wrong parameters for method with unnamed splat [[:rest, :@unnamed_splat]]
Wrong parameters for proc with splat and block [[:rest, :args], [:block, :block], [:block, :options]]

and the output on rbx-2.0.rc1 is:

Wrong parameters for method with unnamed splat [[:rest, :@unnamed_splat]]
Wrong parameters for method with splat and block [[:rest, :args], [:block, :block], [:block, :options], [:block, :foo]]
Wrong parameters for proc with splat and block [[:rest, :args], [:block, :block], [:block, :options]]

the output on MRI 1.9.3 is empty.

I suspect that the problem lies somewhere here:
https://github.com/rubinius/rubinius/blob/master/kernel/common/compiled_code.rb#L515-L538

and here:
https://github.com/rubinius/rubinius/blob/master/kernel/common/proc.rb#L91-L120

I'd add a fix for this myself, but for some reason I can't get rbx to compile (spits out tons of debug output).

@dbussink
Copy link
Contributor

What is the exact version of Rubinius? The reporting multiple parameters as block has been fixed here: 215c42d

What exactly is the compile issue? Are you perhaps on a 32 bit system? I've just fixed an issue with the JIT compiler on 32 bit system, that could show as a lot of debug output.

@psyho
Copy link
Author

psyho commented Jun 25, 2013

Yes, I'm on a 32bit Ubuntu 12.04 and the version I'm trying to compile is 8875d77. It doesn't seem that the recent changes have made any difference.

The commit you are referring to indeed fixed one of the issues with parameters (hence the shorter output on rbx-head), but it only fixed that issue for methods, not for procs, and methods still return a weird '@unnamed_splat' for methods with unnamed splat argument.

@dbussink
Copy link
Contributor

Ah ok, well, I still have the fix for 32 bit here locally only, so will push that shortly together with fixes for these two issues.

@dbussink
Copy link
Contributor

This issue should be fixed now :)

@psyho
Copy link
Author

psyho commented Jun 26, 2013

Thanks. It works now.

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

2 participants