summaryrefslogtreecommitdiff
path: root/proc.c
AgeCommit message (Collapse)Author
13 hours[ci-skip] Shorter example for `Module#instance_method`OKURA Masafumi
The previous example code was too complex and includes extra logics that's not relevant to its main usage: `bind`. The new example code focuses on `bind_call` so that readers can understand how it works more easily.
9 days[DOC] Harmonize #== methods (#15805)Burdette Lamar
2025-12-30[Bug #21783] Fix documentation of {Method,UnboundMethod,Proc}#source_locationBenoit Daloze
2025-12-30Reapply "[Feature #6012] Extend `source_location` for end positionBenoit Daloze
* This reverts commit 065c48cdf11a1c4cece84db44ed8624d294f8fd5. * This functionality is very valuable and has already taken 14 years to agree on the API. * Let's just document it's byte columns (in the next commit). * See https://bugs.ruby-lang.org/issues/21783#note-9
2025-12-29Add rb_gc_register_pinning_objPeter Zhu
2025-12-26[DOC] Use self in call-seq for Method#callPeter Zhu
2025-12-26[DOC] Remove args from call-seq of Method#callPeter Zhu
2025-12-23[DOC] Combine docs for Method#call aliasesPeter Zhu
RDoc does not parse the documentation for the Method#call aliases, so we should combine the aliases into one documentation.
2025-12-22[DOC] Improve call-seq of Proc#callPeter Zhu
2025-12-21[DOC] Improve docs for Method#>>Peter Zhu
2025-12-21[DOC] Update call-seq for Method#>>Peter Zhu
2025-12-21[DOC] Improve docs for Method#<<Peter Zhu
2025-12-21[DOC] Update call-seq for Method#<<Peter Zhu
2025-12-18RBOOL is unnecessary in C boolean contextNobuyoshi Nakada
Fix a `-Wint-in-bool-context` warning. ``` proc.c:688:33: warning: '?:' using integer constants in boolean context [-Wint-in-bool-context] 688 | if (RBOOL(get_local_variable_ptr(&env, idItImplicit, FALSE))) { ```
2025-12-16[DOC] Fix call-seq of Method#boxPeter Zhu
2025-12-16Revert "[Feature #6012] Extend `source_location` for end positionNobuyoshi Nakada
and columns" This reverts commit 073c4e1cc712064e626914fa4a5a8061f903a637. https://bugs.ruby-lang.org/issues/6012#note-31 > we will cancel this feature in 4.0 because of design ambiguities > such as whether to return column positions in bytes or characters as > in [#21783]. [#21783]: https://bugs.ruby-lang.org/issues/21783
2025-12-13Fix binding.implicit_parameters_get/defined segfault when wrong name string ↵tomoya ishida
is passed (#15530)
2025-12-12Add docs to Binding#numbered_parameters, etc.Yusuke Endoh
2025-12-12Binding#implicit_parameters, etc. support the implicit "it" parameterYusuke Endoh
[Bug #21049]
2025-12-12Add Binding#implicit_parameters, etc.Yusuke Endoh
This changeset introduces: * `Binding#implicit_parameters` * `Binding#implicit_parameter_get` * `Binding#implicit_parameter_defined?` [Bug #21049]
2025-12-12Binding#local_variable_defined? raises a NameError for numbered params.Yusuke Endoh
[Bug #21776]
2025-12-12`Binding#local_variable_defined?` must not handle numbered parametersYusuke Endoh
[Bug #21776]
2025-12-05Method and UnboundMethod can be sharableKoichi Sasada
with `RUBY_TYPED_FROZEN_SHAREABLE_NO_REC`, if the receiver object is shareable on Method objects.
2025-11-07renaming internal data structures and functions from namespace to boxSatoshi Tagomori
2025-09-29Update current namespace management by using control frames and lexical contextsSatoshi Tagomori
to fix inconsistent and wrong current namespace detections. This includes: * Moving load_path and related things from rb_vm_t to rb_namespace_t to simplify accessing those values via namespace (instead of accessing either vm or ns) * Initializing root_namespace earlier and consolidate builtin_namespace into root_namespace * Adding VM_FRAME_FLAG_NS_REQUIRE for checkpoints to detect a namespace to load/require files * Removing implicit refinements in the root namespace which was used to determine the namespace to be loaded (replaced by VM_FRAME_FLAG_NS_REQUIRE) * Removing namespaces from rb_proc_t because its namespace can be identified by lexical context * Starting to use ep[VM_ENV_DATA_INDEX_SPECVAL] to store the current namespace when the frame type is MAGIC_TOP or MAGIC_CLASS (block handlers don't exist in this case)
2025-09-11Fix out-of-bounds read in Method#inspect for unnamed parametersPeter Zhu
For parameters without names, accessing the name in array index 1 would be an out-of-bounds read.
2025-08-22Do not respect ruby2_keywords on method/proc with post argumentsJeremy Evans
Previously, ruby2_keywords could be used on a method or proc with post arguments, but I don't think the behavior is desired: ```ruby def a(*c, **kw) [c, kw] end def b(*a, b) a(*a, b) end ruby2_keywords(:b) b({foo: 1}, bar: 1) ``` This changes ruby2_keywords to emit a warning and not set the flag on a method/proc with post arguments. While here, fix the ruby2_keywords specs for warnings, since they weren't testing what they should be testing. They all warned because the method didn't accept a rest argument, not because it accepted a keyword or keyword rest argument.
2025-08-18Add missing writebarrier to rb_func_proc_dupJohn Hawthorn
Because TypedData_Make_Struct both allocates an object and after xmallocs memory, all added references must always be writebarrier protected.
2025-08-04[DOC] Fill undocumented documentsNobuyoshi Nakada
2025-06-17* adjust indentNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13634
2025-06-06proc.c: saves Binding#clone on copying ivars twiceJean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/13541
2025-05-21Fix one-by-one error of numbered parameter IDRichard Böhme
Notes: Merged: https://github.com/ruby/ruby/pull/13395
2025-05-21Shrink `sym_proc_cache` by halfJean Boussier
There is no need to store the symbol and the proc given the proc has a reference to the symbol. This makes the cache half as small, now fitting in an object slot, but also make it easier to allow that cache to be used by ractors, assuming we'd make `Symbol#to_proc` return a shareable proc. Notes: Merged: https://github.com/ruby/ruby/pull/13390
2025-05-21Fix Symbol#to_proc (rb_sym_to_proc) to be ractor safeLuke Gruber
In non-main ractors, don't use `sym_proc_cache`. It is not thread-safe to add to this array without a lock and also it leaks procs from one ractor to another. Instead, we create a new proc each time. If this results in poor performance we can come up with a solution later. Fixes [Bug #21354] Notes: Merged: https://github.com/ruby/ruby/pull/13380
2025-05-20[DOC] Describe new return value of source_locationDaisuke Aritomo
Proc#source_location, Method#source_location and UnboundMethod#source_location carry more information since 073c4e1cc712064e626914fa4a5a8061f903a637. https://bugs.ruby-lang.org/issues/6012 https://github.com/ruby/ruby/pull/12539 Notes: Merged: https://github.com/ruby/ruby/pull/13370
2025-05-11Prevent a compile error of clang's -Wformat-pedanticYusuke Endoh
``` /github/workspace/src/proc.c:2023:65: error: format specifies type 'void *' but the argument has type 'const rb_namespace_t *' (aka 'const struct rb_namespace_struct *') [-Werror,-Wformat-pedantic] 2023 | rb_bug("Unexpected namespace on the method definition: %p", ns); | ~~ ^~ ```
2025-05-11namespace on readSatoshi Tagomori
2025-04-03Remove no longer used unionNobuyoshi Nakada
IMEMO_NEW takes just one memo value, min/max argc are assigned directly and packed argc is not used.
2025-03-16Fix enums in comparisonsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12941
2025-02-20Revert "refactor: make get_local_variable_ptr accept "rb_env_t *""Yusuke Endoh
This reverts commit 6d75599a1aade9f8081d0691a9da1e62a5428e95. Updating env was actually needed in local_variable_set. Alan Wu pointed this out to me. Notes: Merged: https://github.com/ruby/ruby/pull/12783
2025-02-18reject numbered parameters from Binding#local_variablesYusuke Endoh
Also, Binding#local_variable_get and #local_variable_set rejects an access to numbered parameters. [Bug #20965] [Bug #21049] Notes: Merged: https://github.com/ruby/ruby/pull/12746
2025-02-18refactor: make get_local_variable_ptr accept "rb_env_t *"Yusuke Endoh
... instead of "rb_env_t **" because no one uses the updated env. Notes: Merged: https://github.com/ruby/ruby/pull/12746
2025-02-01[Bug #21103] Fix local variable index calculation with forwardingNobuyoshi Nakada
Forwarding argument is optimized not to packed when no other arguments and an internal object refers values before it. This size is decided at called time, calculate the local variable index from the fixed end point. Notes: Merged: https://github.com/ruby/ruby/pull/12686
2025-01-20Remove dead function rb_func_proc_newPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12566
2025-01-13Proc#parameters: Show anonymous optionals as `[:opt]`Alan Wu
Have this for lead parameters as well as parameters after rest ("post"). [Bug #20974] Notes: Merged: https://github.com/ruby/ruby/pull/12547
2025-01-09[Feature #6012] Extend `source_location` for end position and columnsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12539
2025-01-05Use a single quote instead of a backtick for error messagesJunichi Ito
Fix https://bugs.ruby-lang.org/issues/20977 Notes: Merged: https://github.com/ruby/ruby/pull/12424
2025-01-02[DOC] Exclude 'Method' from RDoc's autolinkingNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12496
2024-12-18Document 'it' and update numbered parameters docs (#12375)Victor Shepelev
Notes: Merged-By: zverok <zverok.offline@gmail.com>
2024-12-13Fix use-after-free in ep in Proc#dup for ifunc procsPeter Zhu
[Bug #20950] ifunc proc has the ep allocated in the cfunc_proc_t which is the data of the TypedData object. If an ifunc proc is duplicated, the ep points to the ep of the source object. If the source object is freed, then the ep of the duplicated object now points to a freed memory region. If we try to use the ep we could crash. For example, the following script crashes: p = { a: 1 }.to_proc 100.times do p = p.dup GC.start p.call rescue ArgumentError end This commit changes ifunc proc to also duplicate the ep when it is duplicated. Notes: Merged: https://github.com/ruby/ruby/pull/12319