| Age | Commit message (Collapse) | Author |
|
The return value of Module#set_temporary_name was changed
to return `self`, but the existing tests
did not verify this.
|
|
This provides information on the class of the frozen object. It also
results in a much simpler implementation.
Fixes [Bug #21374]
|
|
The test is no longer useful since
5c7dfe85a1dc49334e2828791f0ade42eee662db because Module#initialize_copy
is empty/not defined anymore.
|
|
Previously, you could override the class initialize_dup/initialize_clone
method and the class hierarchy would not be set correctly inside the
method before calling super.
This removes Module#initialize_copy, and instead makes Object#dup/clone
call the underlying C function (rb_mod_init_copy) before calling the
appropriate initialize_dup/initialize_clone method.
This results in the following fixes:
* The appropriate initialize_dup method is called (dup on a class
will respect superclass initialize_dup).
* Inside class initialize_dup/initialize_clone/initialize_copy,
class ancestor hierarchy is correct.
* Calling singleton_class inside initialize_dup no longer raises
a TypeError later in dup.
* Calling singleton_class.ancestors inside initialize_dup no
longer results in missing ancestors.
Fixes [Bug #21538]
|
|
|
|
On systems where the Encoding.default_internal defaults to US-ASCII instead
of UTF-8, some tests using assert_raise_with_message can fail since it no
longer changes Encoding.default_internal in 79f5202.
This tests explicitly uses EnvUtil.with_default_internal on systems where
these tests fail.
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12947
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12819
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12740
|
|
|
|
[Feature #20912]
Notes:
Merged: https://github.com/ruby/ruby/pull/12177
|
|
subclasses
This bug was present since the code was originally added by me
in 3556a834a2847e52162d1d3302d4c64390df1694.
Fixes [Bug #20871]
Notes:
Merged: https://github.com/ruby/ruby/pull/12125
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12114
|
|
Fixes [Bug #19749]
|
|
[Feature #16495]
|
|
[Bug #20245]
We sometimes pass in a fake string to sym_check_asciionly. This can crash
if sym_check_asciionly raises because it creates a CFP with the fake
string as the receiver which will crash if GC tries to mark the CFP.
For example, the following script crashes:
GC.stress = true
Object.const_defined?("\xC3")
|
|
fix leak in module clone
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
|
|
fix memory leak in vm_method
This introduces a unified reference_count to clarify who is referencing a method.
This also allows us to treat the refinement method as the def owner since it counts itself as a reference
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
|
|
[Bug #19894]
When a copy of a complemented method entry is created, there are two
issues:
1. IMEMO_FL_USER3 is not copied, so the complemented status is not
copied over.
2. In rb_method_entry_clone we increment both alias_count and
complemented_count. However, when we free the method entry in
rb_method_definition_release, we only decrement one of the two
counters, resulting in the rb_method_definition_t being leaked.
Co-authored-by: Adam Hess <adamhess1991@gmail.com>
|
|
|
|
[Bug #19550]
If !RCLASS_EXT_EMBEDDED (e.g. 32 bit systems) then the rb_classext_t is
allocated throug malloc so it must be freed.
The issue can be seen in the following script:
```
20.times do
100_000.times do
mod = Module.new
Class.new do
include mod
end
end
# Output the Resident Set Size (memory usage, in KB) of the current Ruby process
puts `ps -o rss= -p #{$$}`
end
```
Before this fix, the max RSS is 280MB, while after this change, it's
30MB.
Notes:
Merged: https://github.com/ruby/ruby/pull/7597
|
|
* Fix temporary methods on Object leaking across test cases.
* Remove temporary classes/modules leaking across test cases.
Notes:
Merged: https://github.com/ruby/ruby/pull/7513
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/7462
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/7462
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/6950
|
|
Previously, the frozen check happened on `RCLASS_ORIGIN(self)`, which
can return an iclass. The frozen check is supposed to respond to objects
that users can call methods on while iclasses are hidden from users.
Other mutation methods like Module#{define_method,alias_method,public}
don't do this. Check frozen status on the module itself.
Fixes [Bug #19164] and [Bug #19166].
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Notes:
Merged: https://github.com/ruby/ruby/pull/6842
Merged-By: XrXr
|
|
Investigating:
http://ci.rvm.jp/logfiles/brlog.trunk-mjit.20220906-025646
which is not immediately reproducible on my laptop.
|
|
Fixes case where Object includes a module that defines a constant,
then using class/module keyword to define the same constant on
Object itself.
Implements [Feature #18832]
Notes:
Merged: https://github.com/ruby/ruby/pull/6048
|
|
Implements [Feature #12655]
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Notes:
Merged: https://github.com/ruby/ruby/pull/5733
Merged-By: jeremyevans <code@jeremyevans.net>
|
|
Previously in some when classes were duped (specifically those with a
prepended module), they would not correctly have their "superclasses"
array or depth filled in.
This could cause ancestry checks (like is_a? and Module comparisons) to
return incorrect results.
This happened because rb_mod_init_copy builds origin classes in an order
that doesn't have the super linked list fully connected until it's
finished. This commit fixes the previous issue by calling
rb_class_update_superclasses before returning the cloned class. This is
similar to what's already done in make_metaclass.
Notes:
Merged: https://github.com/ruby/ruby/pull/5808
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/5642
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/5455
|
|
[Feature #17881]
Works similarly to `method_added` but for constants.
```ruby
Foo::BAR = 42 # call Foo.const_added(:FOO)
class Foo::Baz; end # call Foo.const_added(:Baz)
Foo.autoload(:Something, "path") # call Foo.const_added(:Something)
```
Notes:
Merged: https://github.com/ruby/ruby/pull/4521
|
|
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Notes:
Merged: https://github.com/ruby/ruby/pull/5398
|
|
This is to allow Module subclasses that include modules before
calling super in the subclass's initialize.
Remove rb_module_check_initializable from Module#initialize.
Module#initialize only calls module_exec if a block is passed,
it doesn't have other issues that would cause problems if
called multiple times or with an already initialized module.
Move initialization of super to Module#allocate, though I'm not
sure it is required there. However, it's needed to be removed
from Module#initialize for this to work.
Fixes [Bug #18292]
Notes:
Merged: https://github.com/ruby/ruby/pull/5398
|
|
Previously, each of these methods returned self, but it is
more useful to return arguments, to allow for simpler method
decorators, such as:
```ruby
cached private def foo; some_long_calculation; end
```
Where cached sets up caching for the method.
For each of these methods, the following behavior is used:
1) No arguments returns nil
2) Single argument is returned
3) Multiple arguments are returned as an array
The single argument case is really the case we are trying to
optimize for, for the same reason that def was changed to return
a symbol for the method.
Idea and initial patch from Herwin Quarantainenet.
Implements [Feature #12495]
Notes:
Merged: https://github.com/ruby/ruby/pull/5037
|
|
Make `Module#ancestors` not to include `BasicObject`.
Notes:
Merged: https://github.com/ruby/ruby/pull/4883
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/4883
|
|
The module that is about to be included is considered initialized.
Notes:
Merged: https://github.com/ruby/ruby/pull/4868
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/4858
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/4858
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/4813
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/4813
|
|
Before this commit, const_get with inherit=true and constant lookup
expressions searched the ancestors of the starting point in an order
different from `starting_point.ancestors`.
Items in the ancestry list introduced through prepend were searched
after searching the module they were prepended into. This oddity allowed
for situations where constant lookups gave different results even though
`starting_point.ancestors` is the same.
Do the lookup in the same order as `starting_point.ancestors` by
skipping classes and modules that have an origin iclass. The origin
iclass is in the super chain after the prepended modules.
Note that just like before this commit, the starting point of the
constant lookup is always the first item that we search, regardless of
the presence of any prepended modules.
[Bug #17887]
Notes:
Merged: https://github.com/ruby/ruby/pull/4585
|
|
```
$ ./local/bin/ruby -e '1.time {}'
-e:1:in `<main>': undefined method `time' for 1:Integer (NoMethodError)
1.time {}
^^^^^
Did you mean? times
```
https://bugs.ruby-lang.org/issues/17930
Notes:
Merged: https://github.com/ruby/ruby/pull/4586
|
|
If a class has been refined but does not have an origin class,
there is a single method entry marked with VM_METHOD_TYPE_REFINED,
but it contains the original method entry. If the original method
entry is present, we shouldn't skip the method when searching even
when skipping refined methods.
Fixes [Bug #17519]
Notes:
Merged: https://github.com/ruby/ruby/pull/4357
|
|
Previously, attempting to change the visibility of a method in a
singleton class for a class/module that is prepended to and refined
would raise a NoMethodError.
Fixes [Bug #17519]
Notes:
Merged: https://github.com/ruby/ruby/pull/4200
|
|
It's important to only make the origin when the prepend goes
through, as the precense of the origin informs whether to do an
origin backfill.
This plus 2d877327e fix [Bug #17590].
Notes:
Merged: https://github.com/ruby/ruby/pull/4181
|
|
Check for cyclic prepend before making any changes. This requires
scanning the module ancestor chain twice, but in general modules
do not have large numbers of ancestors.
Notes:
Merged: https://github.com/ruby/ruby/pull/4165
|
|
in receiver
Previously, if a class included a module and then prepended the
same module, the prepend had no effect. This changes the behavior
so that the prepend has an effect unless the module is already
prepended the receiver.
While here, rename the origin_seen variable in include_modules_at,
since it is misleading. The variable tracks whether c has been seen,
not whether the origin of klass has been.
Fixes [Bug #17423]
Notes:
Merged: https://github.com/ruby/ruby/pull/4072
|