32 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 3fc7dd1858 mruby-proc-ext: Proc#curry should check max arity for lambdas
`lambda {|a, b=nil|}.curry(3)` used to silently return a curried Proc;
CRuby raises `ArgumentError` because the lambda accepts at most 2 args.
Use `self.parameters` to compute the upper bound (count `:req`/`:opt`
entries, unbounded if `:rest`/`:keyrest` is present) and add the
corresponding range check alongside the existing minimum check.

close #2855

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-11 14:06:28 +09:00
Yukihiro "Matz" Matsumoto 87f406581b mruby-proc-ext: combine variable declaration with initialization 2025-10-26 20:33:06 +09:00
Yukihiro "Matz" Matsumoto 23d5e04fdf mruby-proc-ext/test: fix wrong usage of mrb_module_function() 2025-03-07 17:17:41 +09:00
Yukihiro "Matz" Matsumoto 9c5812a463 mruby-compier: keep stack reference to passed block after modifying &b
To mark `MRB_PROC_ORPHAN` we need to keep track of passed block, even
after the assignment to the block argument. And `yield` should use the
original block; #5786, #5791, #6369
2024-09-26 02:48:16 +09:00
Yukihiro "Matz" Matsumoto f1a3cfbd3b add a space between if and ( 2023-05-22 11:55:21 +09:00
Yukihiro "Matz" Matsumoto ea1bc39b52 mruby-proc-ext/proc.c (mrb_proc_inspect): update the format. 2022-10-04 11:05:15 +09:00
Yukihiro "Matz" Matsumoto db7d40be85 mruby-proc-ext/proc.c (mrb_proc_parameters): disclose unnamed arguments.
Unnamed arguments (*, **, &) should be disclosed in the parameter list.
The test is also updated.
2022-09-30 22:19:59 +09:00
John Bampton 9d32d440eb feat(CI): add the GitHub Super Linter
The GitHub Super Linter is a more robust and better supported
tool than the current GitHub Actions we are using.

Running these checks:

ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_BASH: true
VALIDATE_BASH_EXEC: true
VALIDATE_EDITORCONFIG: true
VALIDATE_MARKDOWN: true
VALIDATE_SHELL_SHFMT: true
VALIDATE_YAML: true

https://github.com/marketplace/actions/super-linter
https://github.com/github/super-linter

Added the GitHub Super Linter badge to the README.

Also updated the pre-commit framework and added
more documentation on pre-commit.

Added one more pre-commit check: check-executables-have-shebangs

Added one extra check for merge conflicts to our
GitHub Actions.

EditorConfig and Markdown linting.

Minor grammar and spelling fixes.

Update linter.yml
2021-04-16 16:37:52 +09:00
KOBAYASHI Shuji 35b2798a5d Fix enable_debug_info? in mrbgems/mruby-proc-ext/test/proc.rb 2021-04-15 15:49:23 +09:00
fundamental c146e81c4a Disable tests on backtraces w/ unknown line numbers 2021-03-30 20:26:10 -04:00
dearblue f0a64329b1 Prohibit array changes by "a"/"*" specifier of mrb_get_args()
The "a"/"*" specifier of the `mrb_get_args()` function will now return `const mrb_value *`.
This is because it is difficult for the caller to check if it is an array object and write-barrier if necessary.
And it requires calling `mrb_ary_modify()` on the unmodified array object, which is also difficult (this is similar to #5087).
2020-10-22 22:55:35 +09:00
KOBAYASHI Shuji 3b9b326d3c Remove redundant colon in Proc#inspect (mruby-proc-ext)
Before this patch:

  $ bin/mruby -e 'p proc{}'  #=> #<Proc:0x7fd5eb8206d0@-e::1>

After this patch:

  $ bin/mruby -e 'p proc{}'  #=> #<Proc:0x7fd5eb8206d0@-e:1>
2019-06-11 20:33:07 +09:00
dearblue fc20d0186d Add test for #<< and #>> for Proc and Method class 2019-01-03 18:16:26 +09:00
Tatsuhiko Kubo d2fb4752e2 Add test for Proc#parameters 2018-12-21 12:59:38 +09:00
Yukihiro "Matz" Matsumoto 8f2c62407c Add MRB_METHOD_TABLE_INLINE option.
Now the method tables (in classes/modules and caches) keeps C function
pointers without wrapping in `struct RProc` objects. For the sake of
portability, `mrb_method_t` is represented by the struct and union, but
if the most significant bit of the pointer is not used by the platform,
`mrb_method_t` should be packed in `uintptr_t` to reduce memory usage.

`MRB_METHOD_TABLE_INLINE` is turned on by default for linux.
2017-11-20 18:33:41 +09:00
Christopher Aue 35deaae776 Tested LocalJumpErrors caused by break in a proc 2017-08-30 12:25:55 +02:00
ksss be5c304b4c Fix parameters when noname rest 2017-04-02 23:30:05 +09:00
ksss 3cba13c249 Proc shouldn't have initialize method
Fix #3356
2016-12-21 15:17:05 +09:00
Francois Chagnon 1ec5994377 Fix calling .arity on Proc with undefined initialize
Reported by @bouk
2016-11-24 10:23:31 -05:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
cremno 69b4c1648a Proc#curry should preserve lambdas 2015-06-22 16:35:54 +02:00
ksss 9cafc5e105 Implement Proc#parameters 2014-06-25 16:05:33 +09:00
take_cheeze 2c451dd1fc Use assert_kind_of instead. 2014-05-24 23:18:03 +09:00
take_cheeze d8d07a2345 Move Kernel.local_variables to core. 2014-05-19 22:05:02 +09:00
take_cheeze 0f742392b5 Add ISO index to Kernel.local_variables. 2014-05-18 23:34:56 +09:00
Yukihiro "Matz" Matsumoto 27df1a84bc Kernel.local_variables to list UPVAR as well 2014-05-14 17:38:27 +09:00
take_cheeze 7ea82fedd5 Implement Kernel.local_variables for testing dumped local variables information. 2014-04-29 20:47:50 +09:00
Takeshi Watanabe 6e0c48d758 Fix and add test to Proc#inspect . 2014-04-14 22:01:52 +09:00
take_cheeze bf6b1dfe21 Add API to define cfunc Proc with userdata.
The APIs are defined in mruby-proc-ext so include it before using this API.
See mruby-proc-ext's test code for usage.
This should resolve #1794.
2014-03-31 10:01:17 +09:00
take_cheeze f8270ee59b fix and add test for Proc#source_location 2014-03-06 03:40:41 +09:00
Daniel Bovensiepen 8936965945 Improve test of mruby-proc-ext GEM 2013-08-04 22:41:56 +08:00
h2so5 1a375c6fd4 Add mruby-proc-ext 2013-04-17 22:59:57 +09:00