<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_method.rb, branch v3_3_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Fix UnboundMethod#== for methods from included/extended modules [Backport #21873]</title>
<updated>2026-02-12T06:05:36+00:00</updated>
<author>
<name>Mike Dalessio</name>
<email>mike@37signals.com</email>
</author>
<published>2026-02-10T17:19:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b952b6f099af08a14b57afc0a069597646f3161a'/>
<id>b952b6f099af08a14b57afc0a069597646f3161a</id>
<content type='text'>
Method#unbind clones the method entry, preserving its defined_class.
For methods mixed in via include/extend, defined_class is an ICLASS,
causing UnboundMethod#== to return false when comparing against the
same method obtained via Module#instance_method.

Resolve ICLASS defined_class in method_eq.

[Bug #21873]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Method#unbind clones the method entry, preserving its defined_class.
For methods mixed in via include/extend, defined_class is an ICLASS,
causing UnboundMethod#== to return false when comparing against the
same method obtained via Module#instance_method.

Resolve ICLASS defined_class in method_eq.

[Bug #21873]
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 56ecc243e230e8e99761ec0ffc5116601f094bb0: [Backport #20868]</title>
<updated>2025-01-15T01:40:39+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-01-15T01:40:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=42f043c1893b320b9d2a38ec3b1065dee71ce863'/>
<id>42f043c1893b320b9d2a38ec3b1065dee71ce863</id>
<content type='text'>
	[Bug #20868] Fix Method#hash to not change after compaction

	The hash value of a Method must remain constant after a compaction, otherwise
	it may not work as the key in a hash table.

	For example:

	    def a; end

	    # Need this method here because otherwise the iseq may be on the C stack
	    # which would get pinned and not move during compaction
	    def get_hash
	      method(:a).hash
	    end

	    puts get_hash # =&gt; 2993401401091578131

	    GC.verify_compaction_references(expand_heap: true, toward: :empty)

	    puts get_hash # =&gt; -2162775864511574135
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #20868] Fix Method#hash to not change after compaction

	The hash value of a Method must remain constant after a compaction, otherwise
	it may not work as the key in a hash table.

	For example:

	    def a; end

	    # Need this method here because otherwise the iseq may be on the C stack
	    # which would get pinned and not move during compaction
	    def get_hash
	      method(:a).hash
	    end

	    puts get_hash # =&gt; 2993401401091578131

	    GC.verify_compaction_references(expand_heap: true, toward: :empty)

	    puts get_hash # =&gt; -2162775864511574135
</pre>
</div>
</content>
</entry>
<entry>
<title>Skip under_gc_compact_stress on s390x (#10073)</title>
<updated>2024-05-29T18:13:02+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2024-02-22T22:34:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2f4fe76eff0a8c6ab7a1d2fb845453acfc3cb206'/>
<id>2f4fe76eff0a8c6ab7a1d2fb845453acfc3cb206</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 081ee3d35509110f383cb7dd8d1205def0cdd1e8,1c97abaabae6844c861705fd07f532292dcffa74: [Backport #19907] (#10315)</title>
<updated>2024-03-21T02:23:21+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>nurse@users.noreply.github.com</email>
</author>
<published>2024-03-21T02:23:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=57a0afe2090b8d05673d650b1e8bf9ae67449b1f'/>
<id>57a0afe2090b8d05673d650b1e8bf9ae67449b1f</id>
<content type='text'>
Add memory leak test for eval kwargs

	De-dup identical callinfo objects

	Previously every call to vm_ci_new (when the CI was not packable) would
	result in a different callinfo being returned this meant that every
	kwarg callsite had its own CI.

	When calling, different CIs result in different CCs. These CIs and CCs
	both end up persisted on the T_CLASS inside cc_tbl. So in an eval loop
	this resulted in a memory leak of both types of object. This also likely
	resulted in extra memory used, and extra time searching, in non-eval
	cases.

	For simplicity in this commit I always allocate a CI object inside
	rb_vm_ci_lookup, but ideally we would lazily allocate it only when
	needed. I hope to do that as a follow up in the future.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add memory leak test for eval kwargs

	De-dup identical callinfo objects

	Previously every call to vm_ci_new (when the CI was not packable) would
	result in a different callinfo being returned this meant that every
	kwarg callsite had its own CI.

	When calling, different CIs result in different CCs. These CIs and CCs
	both end up persisted on the T_CLASS inside cc_tbl. So in an eval loop
	this resulted in a memory leak of both types of object. This also likely
	resulted in extra memory used, and extra time searching, in non-eval
	cases.

	For simplicity in this commit I always allocate a CI object inside
	rb_vm_ci_lookup, but ideally we would lazily allocate it only when
	needed. I hope to do that as a follow up in the future.</pre>
</div>
</content>
</entry>
<entry>
<title>Don't copy RUBY_FL_PROMOTED flag in rb_obj_setup</title>
<updated>2023-12-25T03:13:49+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-12-25T02:26:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b4efa4b7005efee484e61fbc6af9c652fee36db2'/>
<id>b4efa4b7005efee484e61fbc6af9c652fee36db2</id>
<content type='text'>
RUBY_FL_PROMOTED is used by the garbage collector to track when an
object becomes promoted to the old generation. rb_obj_setup must not
copy that flag over because then it may become out-of-sync with the age
of the object.

This fixes a bug in Method#clone where the cloned Method object may get
RUBY_FL_PROMOTED incorrectly set.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
RUBY_FL_PROMOTED is used by the garbage collector to track when an
object becomes promoted to the old generation. rb_obj_setup must not
copy that flag over because then it may become out-of-sync with the age
of the object.

This fixes a bug in Method#clone where the cloned Method object may get
RUBY_FL_PROMOTED incorrectly set.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove --disable-gems for assert_separately</title>
<updated>2023-08-03T00:11:08+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-08-02T21:02:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4b6c584023f41827c891f33a16cb5db221b7cd19'/>
<id>4b6c584023f41827c891f33a16cb5db221b7cd19</id>
<content type='text'>
assert_separately adds --disable=gems so we don't need to add
--disable-gems when calling assert_separately.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
assert_separately adds --disable=gems so we don't need to add
--disable-gems when calling assert_separately.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use the caller location as default filename for eval family of methods</title>
<updated>2023-07-24T12:51:20+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>byroot@ruby-lang.org</email>
</author>
<published>2023-07-13T09:49:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=43a5c191358699fe8b19314763998cb8ca77ed90'/>
<id>43a5c191358699fe8b19314763998cb8ca77ed90</id>
<content type='text'>
[Feature #19755]

Before (in /tmp/test.rb):

```ruby
Object.class_eval("p __FILE__") # =&gt; "(eval)"
```

After:

```ruby
Object.class_eval("p __FILE__") # =&gt; "(eval at /tmp/test.rb:1)"
```

This makes it much easier to track down generated code in case
the author forgot to provide a filename argument.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Feature #19755]

Before (in /tmp/test.rb):

```ruby
Object.class_eval("p __FILE__") # =&gt; "(eval)"
```

After:

```ruby
Object.class_eval("p __FILE__") # =&gt; "(eval at /tmp/test.rb:1)"
```

This makes it much easier to track down generated code in case
the author forgot to provide a filename argument.
</pre>
</div>
</content>
</entry>
<entry>
<title>Handle private AREF call in compile.c</title>
<updated>2023-04-30T14:21:59+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-04-30T14:21:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b82c06a711cbd1f812251a15c1e864027abe8c37'/>
<id>b82c06a711cbd1f812251a15c1e864027abe8c37</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>UnboundMethod only refer defined_class</title>
<updated>2022-12-02T23:53:12+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2022-12-02T20:55:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=59e389af2893c0fcf8b2cfa008c9a16825bf56ff'/>
<id>59e389af2893c0fcf8b2cfa008c9a16825bf56ff</id>
<content type='text'>
UnboundMethod records caller's class, like `D` or `E` on the
following case:

```ruby
class C
  def foo = :foo
end

class D &lt; C
end

class E &lt; C
end

d = D.instance_method(:foo)
e = E.instance_method(:foo)
```

But `d` and `e` only refers `C#foo` so that UnboundMethod doesn't
record `D` or `E`. This behavior changes the following methods:

* `UnboundMethod#inspect` (doesn't show caller's class)
* `UnboundMethod#==` (`d == e` for example)

fix https://bugs.ruby-lang.org/issues/18798
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
UnboundMethod records caller's class, like `D` or `E` on the
following case:

```ruby
class C
  def foo = :foo
end

class D &lt; C
end

class E &lt; C
end

d = D.instance_method(:foo)
e = E.instance_method(:foo)
```

But `d` and `e` only refers `C#foo` so that UnboundMethod doesn't
record `D` or `E`. This behavior changes the following methods:

* `UnboundMethod#inspect` (doesn't show caller's class)
* `UnboundMethod#==` (`d == e` for example)

fix https://bugs.ruby-lang.org/issues/18798
</pre>
</div>
</content>
</entry>
<entry>
<title>Suppress a "warning: method redefined" in test/ruby/test_method.rb</title>
<updated>2022-10-12T12:51:23+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2022-10-12T12:51:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=504e388525ca7a1eeac64d08731f036b2ffc7b07'/>
<id>504e388525ca7a1eeac64d08731f036b2ffc7b07</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
