<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_call.rb, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[Bug #19021] Fix safe call w/ conditional assign</title>
<updated>2022-09-26T03:44:54+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2022-09-26T02:54:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b361bdc20036688f17f1e39a260a70254e7db9cd'/>
<id>b361bdc20036688f17f1e39a260a70254e7db9cd</id>
<content type='text'>
As of fbaac837cfba23a9d34dc7ee144d7940248222a2, when we were performing
a safe call (`o&amp;.x=`) with a conditional assign (`||= 1`) and discarding
the result the stack would end up in a bad state due to a missing pop.

This commit fixes that by adjusting the target label of the branchnil to
be before a pop in that case (as was previously done in the
non-conditional assignment case).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As of fbaac837cfba23a9d34dc7ee144d7940248222a2, when we were performing
a safe call (`o&amp;.x=`) with a conditional assign (`||= 1`) and discarding
the result the stack would end up in a bad state due to a missing pop.

This commit fixes that by adjusting the target label of the branchnil to
be before a pop in that case (as was previously done in the
non-conditional assignment case).
</pre>
</div>
</content>
</entry>
<entry>
<title>Dup splat array in certain cases where there is a block argument</title>
<updated>2020-06-18T15:19:33+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2020-05-28T21:59:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=aae8223c7076483f1f1641181088790b2f3a66dd'/>
<id>aae8223c7076483f1f1641181088790b2f3a66dd</id>
<content type='text'>
This makes:

```ruby
  args = [1, 2, -&gt; {}]; foo(*args, &amp;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, &amp;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; -&gt;{}; end
  foo(*args, &amp;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]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This makes:

```ruby
  args = [1, 2, -&gt; {}]; foo(*args, &amp;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, &amp;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; -&gt;{}; end
  foo(*args, &amp;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]
</pre>
</div>
</content>
</entry>
<entry>
<title>test_call.rb: refine test_safe_call</title>
<updated>2017-10-02T11:43:36+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2017-10-02T11:43:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=548698397a99065717fdc7766eaabf6af7a4026e'/>
<id>548698397a99065717fdc7766eaabf6af7a4026e</id>
<content type='text'>
* test/ruby/test_call.rb (test_safe_call): rhs should not be
  evaluated when the receiver is nil.  simplified the assertion
  for  [Bug #13964].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* test/ruby/test_call.rb (test_safe_call): rhs should not be
  evaluated when the receiver is nil.  simplified the assertion
  for  [Bug #13964].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>compile.c: fix stack consitency error</title>
<updated>2017-10-02T08:33:30+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2017-10-02T08:33:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=896e7f2d8dd7fa190c4514043b3aa5fcfa20c65f'/>
<id>896e7f2d8dd7fa190c4514043b3aa5fcfa20c65f</id>
<content type='text'>
* compile.c (iseq_compile_each0): fix stack consitency error on
  attr-assign with safe navigation operator when the receiver is
  nil, should pop it too.  [ruby-core:83078] [Bug #13964]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* compile.c (iseq_compile_each0): fix stack consitency error on
  attr-assign with safe navigation operator when the receiver is
  nil, should pop it too.  [ruby-core:83078] [Bug #13964]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>compile.c: order with splatting</title>
<updated>2016-10-22T00:52:59+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2016-10-22T00:52:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d506a3521c7ebec78bf1aa2f0015c6cafb785f99'/>
<id>d506a3521c7ebec78bf1aa2f0015c6cafb785f99</id>
<content type='text'>
* compile.c (setup_args): duplicate splatting array if more
  arguments present to obey left-to-right execution order.
  [ruby-core:77701] [Bug# 12860]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* compile.c (setup_args): duplicate splatting array if more
  arguments present to obey left-to-right execution order.
  [ruby-core:77701] [Bug# 12860]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>symbol.h: unexpected safe call</title>
<updated>2016-01-09T09:26:23+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2016-01-09T09:26:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c79402c4f0e40a3ebebda9761e47ff1b3d12ed53'/>
<id>c79402c4f0e40a3ebebda9761e47ff1b3d12ed53</id>
<content type='text'>
* symbol.h (is_attrset_id): ASET is an attrset ID.  fix
  unexpected safe call instead of an ordinary ASET.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* symbol.h (is_attrset_id): ASET is an attrset ID.  fix
  unexpected safe call instead of an ordinary ASET.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>Add frozen_string_literal: false for all files</title>
<updated>2015-12-16T05:07:31+00:00</updated>
<author>
<name>naruse</name>
<email>naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2015-12-16T05:07:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3e92b635fb5422207b7bbdc924e292e51e21f040'/>
<id>3e92b635fb5422207b7bbdc924e292e51e21f040</id>
<content type='text'>
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>parse.y: fix block_call&amp;.call</title>
<updated>2015-12-16T01:49:42+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2015-12-16T01:49:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=bfd34365b6b01898649cfd570306e062c170628b'/>
<id>bfd34365b6b01898649cfd570306e062c170628b</id>
<content type='text'>
* parse.y (block_command, block_call): fix `&amp;.` calls after
  block_call.  [Feature #11537]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* parse.y (block_command, block_call): fix `&amp;.` calls after
  block_call.  [Feature #11537]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>change DOTQ</title>
<updated>2015-11-06T03:39:23+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2015-11-06T03:39:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=837babd56459aafc1232a12fbfa783025d619b98'/>
<id>837babd56459aafc1232a12fbfa783025d619b98</id>
<content type='text'>
* defs/id.def (token_ops), parse.y (parser_yylex): change DOTQ
  from ".?" to "&amp;.".  [ruby-core:71363] [Feature #11537]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* defs/id.def (token_ops), parse.y (parser_yylex): change DOTQ
  from ".?" to "&amp;.".  [ruby-core:71363] [Feature #11537]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>parse.y: revert lbracket</title>
<updated>2015-11-03T00:27:04+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2015-11-03T00:27:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a3ee54f8a653f2e7c8ea88ef5ee9f3a49a248447'/>
<id>a3ee54f8a653f2e7c8ea88ef5ee9f3a49a248447</id>
<content type='text'>
* parse.y (lbracket): remove .? before aref.  [Feature #11537]
  revert r52422 and r52424

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* parse.y (lbracket): remove .? before aref.  [Feature #11537]
  revert r52422 and r52424

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
</feed>
