1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test
Jeremy Evans aae8223c70 Dup splat array in certain cases where there is a block argument
This makes:

```ruby
  args = [1, 2, -> {}]; foo(*args, &args.pop)
```

call `foo` with 1, 2, and the lambda, in addition to passing the
lambda as a block.  This is different from the previous behavior,
which passed the lambda as a block but not as a regular argument,
which goes against the expected left-to-right evaluation order.

This is how Ruby already compiled arguments if using leading
arguments, trailing arguments, or keywords in the same call.

This works by disabling the optimization that skipped duplicating
the array during the splat (splatarray instruction argument
switches from false to true).  In the above example, the splat
call duplicates the array.  I've tested and cases where a
local variable or symbol are used do not duplicate the array,
so I don't expect this to decrease the performance of most Ruby
programs.  However, programs such as:

```ruby
  foo(*args, &bar)
```

could see a decrease in performance, if `bar` is a method call
and not a local variable.

This is not a perfect solution, there are ways to get around
this:

```ruby
  args = Struct.new(:a).new([:x, :y])
  def args.to_a; a; end
  def args.to_proc; a.pop; ->{}; end
  foo(*args, &args)
  # calls foo with 1 argument (:x)
  # not 2 arguments (:x and :y)
```

A perfect solution would require completely disabling the
optimization.

Fixes [Bug #16504]
Fixes [Bug #16500]
2020-06-18 08:19:33 -07:00
..
-ext- Make Thread#thread_variable? similar to #thread_variable_get 2020-05-25 21:38:35 -07:00
base64
benchmark
bigdecimal
cgi
coverage
csv Removed trailing spaces [ci skip] 2020-05-14 19:57:39 +09:00
date
dbm
did_you_mean Sync did_you_mean 2020-06-06 13:02:08 -04:00
digest
drb Explicitly loading with envutil.rb 2020-05-28 14:41:08 +09:00
dtrace
erb
etc
excludes
fiber Improved assertions 2020-06-09 21:42:25 +09:00
fiddle [ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33) 2020-05-23 14:34:07 +09:00
fileutils Revert "[ruby/fileutils] Make verbose output go to stdout instead of stderr" 2020-06-12 19:02:50 +09:00
gdbm [ruby/gdbm] Workaround for GitHub Actions 2020-06-09 20:54:52 +09:00
io Use %w instead of %i not to create unused IDs 2020-05-09 20:13:30 +09:00
irb Fix typos 2020-05-09 14:22:04 +09:00
json
lib test/lib/jit_support.rb: Let JIT tests skip on centos8 2020-05-12 17:48:31 +09:00
logger [ruby/logger] Let Logger#reopen not raise on nil log devices 2020-06-11 13:54:04 +09:00
matrix
mkmf
monitor
net Try using longer read_timeout for --jit-wait 2020-06-14 15:01:15 -07:00
nkf
objspace
open-uri
openssl [ruby/openssl] ssl: temporarily remove SSLContext#add_certificate_chain_file 2020-05-13 15:47:51 +09:00
optparse
ostruct
pathname
psych [ruby/psych] Fixing compatibility with libyaml 0.2.5 2020-06-05 11:49:56 +09:00
racc
rdoc [ruby/rdoc] Check uninitialized instance variable in test 2020-05-24 23:47:24 +09:00
readline Restore class variable setting for tests 2020-05-14 12:27:33 +09:00
reline [ruby/reline] Add a test of autowrap for yamatanooroti 2020-05-17 19:26:53 +09:00
resolv
rinda Explicitly loading with envutil.rb 2020-05-28 14:41:08 +09:00
ripper Introduce find pattern [Feature #16828] 2020-06-14 09:24:36 +09:00
ruby Dup splat array in certain cases where there is a block argument 2020-06-18 08:19:33 -07:00
rubygems test/rubygems/test_gem_package.rb: Skip a test when TMPDIR is too long 2020-06-17 23:28:51 +09:00
sdbm
socket test/socket/test_addrinfo.rb: Fix syntax error 2020-06-04 11:29:39 +09:00
stringio
strscan
syslog
uri
webrick lib/webrick/httpservlet/filehandler.rb: always handle a path as UTF-8 2020-06-18 23:43:48 +09:00
win32ole
yaml
zlib
runner.rb
test_abbrev.rb
test_delegate.rb
test_extlibs.rb
test_find.rb
test_forwardable.rb
test_ipaddr.rb
test_mutex_m.rb
test_observer.rb
test_open3.rb
test_pp.rb
test_prettyprint.rb
test_prime.rb
test_pstore.rb
test_pty.rb
test_rbconfig.rb
test_securerandom.rb
test_set.rb Make mutating the result of SortedSet#to_a not affect the set 2020-06-11 14:02:00 -07:00
test_shellwords.rb
test_singleton.rb
test_syslog.rb
test_tempfile.rb
test_time.rb
test_timeout.rb
test_tmpdir.rb Correctly remove temporary directory if path yielded is mutated 2020-05-29 07:06:46 -07:00
test_tracer.rb
test_tsort.rb
test_unicode_normalize.rb
test_weakref.rb
test_win32api.rb