Skip to content

Commit

Permalink
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/language/block_tags.txt
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ fails:A block yielded a single Array assigns elements to required arguments when
fails:A block yielded a single Array assigns the last element to a non-keyword argument if #to_hash returns nil
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
fails:A block yielded a single Array raises a TypeError if #to_hash does not return a Hash
fails:A block yielded a single Object receives the object if #to_ary returns nil
fails:Block-local variables override shadowed variables from the outer scope
fails:Post-args with optional args with a circular argument reference shadows an existing method with the same name as the argument
8 changes: 6 additions & 2 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -274,11 +274,15 @@ module Truffle::Primitive
def self.load_arguments_from_array_kw_helper(array, kwrest_name, binding)
array = array.dup

kwargs = array.pop.to_hash.select { |key, value|
last_arg = array.pop
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)

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

binding.local_variable_set(kwrest_name, kwargs) if kwrest_name
array

0 comments on commit 26f3817

Please sign in to comment.