Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b307b7ee0a89
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9630cbad4717
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 11, 2016

  1. 2
    Copy the full SHA
    bfe5f63 View commit details
  2. Copy the full SHA
    0840d2f View commit details
  3. Copy the full SHA
    9630cba View commit details
Showing with 18 additions and 13 deletions.
  1. +0 −2 spec/truffle/tags/language/block_tags.txt
  2. +18 −11 truffle/src/main/ruby/core/shims.rb
2 changes: 0 additions & 2 deletions spec/truffle/tags/language/block_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
fails:A block yielded a single Array assigns elements to required arguments when a keyword rest argument is present
fails:A block yielded a single Array calls #to_hash on the argument but does not use the result when no keywords are present
fails:A block yielded a single Array calls #to_hash on the last element when there are more arguments than parameters
29 changes: 18 additions & 11 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -275,21 +275,28 @@ def self.load_arguments_from_array_kw_helper(array, kwrest_name, binding)
array = array.dup

last_arg = array.pop
kwargs = last_arg.to_hash

if kwargs.nil?
array.push last_arg
return array
end
if last_arg.is_a? Fixnum
kwargs = {}
else
kwargs = last_arg.to_hash

raise TypeError.new("can't convert #{last_arg.class} to Hash (#{last_arg.class}#to_hash gives #{kwargs.class})") unless kwargs.is_a?(Hash)
if kwargs.nil?
array.push last_arg
return array
end

kwargs.select! do |key, value|
symbol = key.is_a? Symbol
array.push({key => value}) unless symbol
symbol
end
raise TypeError.new("can't convert #{last_arg.class} to Hash (#{last_arg.class}#to_hash gives #{kwargs.class})") unless kwargs.is_a?(Hash)

return array + [kwargs] unless kwargs.keys.any? { |k| k.is_a? Symbol }

kwargs.select! do |key, value|
symbol = key.is_a? Symbol
array.push({key => value}) unless symbol
symbol
end
end

binding.local_variable_set(kwrest_name, kwargs) if kwrest_name
array
end