<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_lambda.rb, branch v4.0.4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Revert "[Feature #6012] Extend `source_location` for end position</title>
<updated>2025-12-16T07:13:07+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-12-16T03:51:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=065c48cdf11a1c4cece84db44ed8624d294f8fd5'/>
<id>065c48cdf11a1c4cece84db44ed8624d294f8fd5</id>
<content type='text'>
and columns"

This reverts commit 073c4e1cc712064e626914fa4a5a8061f903a637.

https://bugs.ruby-lang.org/issues/6012#note-31
&gt; we will cancel this feature in 4.0 because of design ambiguities
&gt; such as whether to return column positions in bytes or characters as
&gt; in [#21783].

[#21783]: https://bugs.ruby-lang.org/issues/21783
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
and columns"

This reverts commit 073c4e1cc712064e626914fa4a5a8061f903a637.

https://bugs.ruby-lang.org/issues/6012#note-31
&gt; we will cancel this feature in 4.0 because of design ambiguities
&gt; such as whether to return column positions in bytes or characters as
&gt; in [#21783].

[#21783]: https://bugs.ruby-lang.org/issues/21783
</pre>
</div>
</content>
</entry>
<entry>
<title>[Feature #6012] Extend `source_location` for end position and columns</title>
<updated>2025-01-09T11:21:41+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-01-09T11:21:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=073c4e1cc712064e626914fa4a5a8061f903a637'/>
<id>073c4e1cc712064e626914fa4a5a8061f903a637</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Make Kernel#lambda raise when given non-literal block</title>
<updated>2023-09-12T15:25:07+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2023-09-07T18:56:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=39ee3e22bd3d071c1c283b6b8dbd1af413342fb1'/>
<id>39ee3e22bd3d071c1c283b6b8dbd1af413342fb1</id>
<content type='text'>
Previously, Kernel#lambda returned a non-lambda proc when given a
non-literal block and issued a warning under the `:deprecated` category.
With this change, Kernel#lambda will always return a lambda proc, if it
returns without raising.

Due to interactions with block passing optimizations, we previously had
two separate code paths for detecting whether Kernel#lambda got a
literal block. This change allows us to remove one path, the hack done
with rb_control_frame_t::block_code introduced in 85a337f for supporting
situations where Kernel#lambda returned a non-lambda proc.

[Feature #19777]

Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, Kernel#lambda returned a non-lambda proc when given a
non-literal block and issued a warning under the `:deprecated` category.
With this change, Kernel#lambda will always return a lambda proc, if it
returns without raising.

Due to interactions with block passing optimizations, we previously had
two separate code paths for detecting whether Kernel#lambda got a
literal block. This change allows us to remove one path, the hack done
with rb_control_frame_t::block_code introduced in 85a337f for supporting
situations where Kernel#lambda returned a non-lambda proc.

[Feature #19777]

Co-authored-by: Takashi Kokubun &lt;takashikkbn@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>test/ruby/test_lambda.rb: Remove "warning: assigned but unused variable"</title>
<updated>2021-04-04T06:26:09+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2021-04-04T06:26:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2fcae4f90ab08ae06c28c4aa0989ee06d97f0536'/>
<id>2fcae4f90ab08ae06c28c4aa0989ee06d97f0536</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>fix return from orphan Proc in lambda</title>
<updated>2021-04-02T00:25:33+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2021-04-01T17:28:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ecfa8dcdbaf60cbe878389439de9ac94bc82e034'/>
<id>ecfa8dcdbaf60cbe878389439de9ac94bc82e034</id>
<content type='text'>
A "return" statement in a Proc in a lambda like:
  `lambda{ proc{ return }.call }`
should return outer lambda block. However, the inner Proc can become
orphan Proc from the lambda block. This "return" escape outer-scope
like method, but this behavior was decieded as a bug.
[Bug #17105]

This patch raises LocalJumpError by checking the proc is orphan or
not from lambda blocks before escaping by "return".

Most of tests are written by Jeremy Evans
https://github.com/ruby/ruby/pull/4223
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A "return" statement in a Proc in a lambda like:
  `lambda{ proc{ return }.call }`
should return outer lambda block. However, the inner Proc can become
orphan Proc from the lambda block. This "return" escape outer-scope
like method, but this behavior was decieded as a bug.
[Bug #17105]

This patch raises LocalJumpError by checking the proc is orphan or
not from lambda blocks before escaping by "return".

Most of tests are written by Jeremy Evans
https://github.com/ruby/ruby/pull/4223
</pre>
</div>
</content>
</entry>
<entry>
<title>test/ruby/test_lambda.rb: prevent lambda(&amp;proc_block) warnings</title>
<updated>2020-12-12T14:11:47+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2020-12-12T14:11:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=efbef729b2aee13241e6f7606f90d407f4530df8'/>
<id>efbef729b2aee13241e6f7606f90d407f4530df8</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Disable deprecation warning by the default [Feature #16345]</title>
<updated>2020-09-25T00:50:33+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2020-08-31T05:58:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=996af2ce086249e904b2ce95ab2fcd1de7d757be'/>
<id>996af2ce086249e904b2ce95ab2fcd1de7d757be</id>
<content type='text'>
And `-w` option turns it on.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
And `-w` option turns it on.
</pre>
</div>
</content>
</entry>
<entry>
<title>Warn when passing a non-literal block to Kernel#lambda</title>
<updated>2020-06-11T14:30:48+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2020-06-11T00:50:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2188d6d160d3ba82432c87277310a4d417e136d5'/>
<id>2188d6d160d3ba82432c87277310a4d417e136d5</id>
<content type='text'>
Implements [Feature #15973]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implements [Feature #15973]
</pre>
</div>
</content>
</entry>
<entry>
<title>Kernel#lambda: return forwarded block as non-lambda proc</title>
<updated>2019-12-21T14:08:52+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2019-07-13T16:04:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=85a337f986fe6da99c7f8358f790f17b122b3903'/>
<id>85a337f986fe6da99c7f8358f790f17b122b3903</id>
<content type='text'>
Before this commit, Kernel#lambda can't tell the difference between a
directly passed literal block and one passed with an ampersand.

A block passed with an ampersand is semantically speaking already a
non-lambda proc. When Kernel#lambda receives a non-lambda proc, it
should simply return it.

Implementation wise, when the VM calls a method with a literal block, it
places the code for the block on the calling control frame and passes a
pointer (block handler) to the callee. Before this commit, the VM
forwards block arguments by simply forwarding the block handler, which
leaves the slot for block code unused when a control frame forwards its
block argument. I use the vacant space to indicate that a frame has
forwarded its block argument and inspect that in Kernel#lambda to detect
forwarded blocks.

This is a very ad-hoc solution and relies *heavily* on the way block
passing works in the VM. However, it's the most self-contained solution
I have.

[Bug #15620]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before this commit, Kernel#lambda can't tell the difference between a
directly passed literal block and one passed with an ampersand.

A block passed with an ampersand is semantically speaking already a
non-lambda proc. When Kernel#lambda receives a non-lambda proc, it
should simply return it.

Implementation wise, when the VM calls a method with a literal block, it
places the code for the block on the calling control frame and passes a
pointer (block handler) to the callee. Before this commit, the VM
forwards block arguments by simply forwarding the block handler, which
leaves the slot for block code unused when a control frame forwards its
block argument. I use the vacant space to indicate that a frame has
forwarded its block argument and inspect that in Kernel#lambda to detect
forwarded blocks.

This is a very ad-hoc solution and relies *heavily* on the way block
passing works in the VM. However, it's the most self-contained solution
I have.

[Bug #15620]
</pre>
</div>
</content>
</entry>
<entry>
<title>add tests for orphan/not-orphan proc/lambda.</title>
<updated>2019-07-15T05:17:27+00:00</updated>
<author>
<name>Tanaka Akira</name>
<email>akr@fsij.org</email>
</author>
<published>2019-07-15T05:17:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e4c1b199961cc5fa34c02b2225bbc14b75259fd2'/>
<id>e4c1b199961cc5fa34c02b2225bbc14b75259fd2</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
