Commit Graph

1081 Commits

Author SHA1 Message Date
John Bampton b4a1e98f2e Rubocop: fix target Ruby version; add two more cops; fix lint error
https://docs.rubocop.org/rubocop/cops_layout.html#layoutassignmentindentation

https://docs.rubocop.org/rubocop/cops_layout.html#layoutblockendnewline
2025-06-25 18:02:53 +10:00
Yukihiro "Matz" Matsumoto ebd9f29b38 The method #initialize_copy should be private, no direct call
Fixed test/t/array.rb and test/t/string.rb in standard tests.
And mrbgems/mruby-struct/test/struct.rb as well.
2025-06-14 13:38:22 +09:00
Paweł Świątkowski bdcd496bc2 Fix calling extended callback
The callback of extending module should be called, not of a singleton
class of an extended object.
2025-05-27 23:03:10 +02:00
dearblue 4417321d1c Add more test code for method visibility
This test corresponds to the first issue of #6494.
Complement to #6512.
2025-05-18 18:50:02 +09:00
Yukihiro "Matz" Matsumoto 21d6bfb6dd test/kernel.rb: disable some Kernel#p tests; ref #6524 2025-05-08 16:21:01 +09:00
Yukihiro "Matz" Matsumoto 5b10fdf684 Merge pull request #6524 from hasumikin/fix/Kernel#p 2025-05-08 16:01:35 +09:00
Yukihiro "Matz" Matsumoto aec8d0c58b Merge branch 'visibility' of github.com:dearblue/mruby into dearblue-visibility 2025-05-07 15:37:08 +09:00
Yukihiro "Matz" Matsumoto a87b4b6bc3 test/exception.rb: update for new Exception#inspect 2025-05-07 12:19:05 +09:00
HASUMI Hitoshi fdfd67ff40 Fix Kernel#p when no argument
## Expected
```ruby
p
=> nil
```

## Actual
```ruby
p
=> []
```
2025-05-04 10:17:37 +09:00
Yukihiro "Matz" Matsumoto 6c72f8b378 class.c (extend_object): remove method; implement Kernel#extend in C 2025-04-28 10:30:00 +09:00
Yukihiro "Matz" Matsumoto 6c25b5896a class.c (prepend_features): remove the method
Just like `#append_features`, we remove `#prepend_features` and
implemented `#prepend` directly in C.
2025-04-28 10:30:00 +09:00
Yukihiro "Matz" Matsumoto 9387cd382e class.c (append_features): remove the method
The technique is called "double dispatch" (that was popular in
Smalltalk), but it does not work well with mruby. It's slower and
consumes more memory. Even thought `#append_features` defined in ISO
standard (15.2.2.4.11), we decided to remove it. Strictly speaking, it
is mruby limitation. And it should be documented clearly.
2025-04-28 10:30:00 +09:00
Yukihiro "Matz" Matsumoto 9cc6d39956 test/module.rb: add test for #6506 2025-04-14 22:09:35 +09:00
dearblue 3fd5e1c250 Fixed visibility at method definition
There was a problem with visibility state from proc that straddles a fiber or is independent.

Therefore, it has been changed to give priority to env objects, if any.
Also, added "separate module" flag to block traversal to a higher level env object.

Note that the "separate module" flag is now set when calling blocks with the `mrb_yield_with_class()` function.

fixed https://github.com/mruby/mruby/issues/6494
2025-04-11 21:36:26 +09:00
dearblue 84e1b0045c Fixed class method visibility via module_function
The following code should work

```ruby
module M
  def me
    p self
  end

  module_function :me
end

M.me
```
2025-04-07 21:40:56 +09:00
Mark Delk 6396aac434 fix a typo, update specs 2025-03-17 10:47:33 -05:00
Yukihiro "Matz" Matsumoto fbaedfeaad test/hash.rb: remove Hash#freeze before Hash#rehash; ref #6485 2025-03-08 11:25:49 +09:00
Yukihiro "Matz" Matsumoto 18674c0237 test/module.rb: add visibility tests; ref #1835 2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto 384579fd21 test/module.rb: rename to pass the spell check 2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto 95b30a38dc kernel.rb: make Kernel#loop private 2025-03-07 17:17:44 +09:00
Yukihiro "Matz" Matsumoto ff6149dea7 kernel.c: removed some Kernel singleton methods
Since virtually no one calls `Kernel.block_given?` but just
`block_given?`. For the cases `raise` is redefined (like Ruby/Tk),
`Kernel.raise` is kept.
2025-03-07 17:17:44 +09:00
Yukihiro "Matz" Matsumoto efc03f60af proc.c: make #lambda private 2025-03-07 17:17:43 +09:00
Yukihiro "Matz" Matsumoto 4d547b6cbb test/module.rb: call #remove_const via #__send__ to skip private check 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto e0cb99aad4 test/module.rb: call #extend_object via #__send__ to skip private check 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto 8a409feaad test/module.rb: call #prepend_features via #__send__ to skip private check 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto 701a18deda test/module.rb: call #append_features via #__send__ to skip private check 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto 7653bdd05e test/codegen.rb: call #remove_const via #__send__ to skip private check 2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto f82cd188b0 test/exception.rb: call #initialize via #__send__ to skip private check 2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto 214ae5aad3 test/array.rb: call #initialize via #__send__ to skip private check 2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto 7981865e18 test/string.rb: call #initialize via #__send__ to skip private check 2025-03-07 17:17:39 +09:00
dearblue 12e90896a5 Moved tests for Integer#quo
The `Rational` class is never defined during core testing.
2025-01-26 21:11:21 +09:00
Yukihiro "Matz" Matsumoto 003e0fb330 mruby-print: disable the gem unless explicitly specified
mruby-print is the duplicate of part of mruby-io. You need it only when
limited I/O functionality required.
2025-01-06 13:57:23 +09:00
Yukihiro "Matz" Matsumoto 6037e50298 test/hash: update tests to new hash format 2024-12-21 08:53:57 +09:00
Yukihiro "Matz" Matsumoto 1dfd3d9043 Merge pull request #6442 from dearblue/jmpuw 2024-12-06 23:43:31 +09:00
Yukihiro "Matz" Matsumoto ac6436556b Merge pull request #6440 from dearblue/redo
Fix `redo` keyword
2024-12-06 23:42:44 +09:00
dearblue 95e2f8e844 Fixed wrong range condition in OP_JMPUW
fixed #6441
2024-12-03 22:14:50 +09:00
Yukihiro "Matz" Matsumoto 94a4b95b5d test/lang.rb: update compiled code in comments
- variable sized instructions
- new instruction names
- remove OP_ prefix as code dump does
2024-12-02 15:23:06 +09:00
dearblue 01ea2c088d Add more tests for redo keyword 2024-12-01 11:33:23 +09:00
Hoshiumi Arata 386cd771e7 Fix numbered parameters when used as hash keys 2024-11-20 00:31:44 +09:00
Yukihiro "Matz" Matsumoto 628f057482 Merge pull request #6419 from hoshiumiarata/fix_numparams_in_lambda 2024-11-15 16:17:03 +09:00
Yukihiro "Matz" Matsumoto e0d9bce8b6 Merge pull request #6415 from hoshiumiarata/fix_numbered_parameters_in_singleton 2024-11-15 16:10:34 +09:00
Yukihiro "Matz" Matsumoto a109599d53 vm.c (prepare_missing): add receiver's class in superclass calls 2024-11-15 15:15:08 +09:00
Yukihiro "Matz" Matsumoto 65e0e5bbd3 class.c (mrb_method_missing): add receiver's class to clarify
We needed to modify a lot of test code that expected the old style.
2024-11-15 15:13:24 +09:00
Hoshiumi Arata 9fe2a5c46a parser: setup numbered parameters in new_lambda and adjust dump_prefix offset 2024-11-13 22:19:27 +09:00
Hoshiumi Arata cc2ec53807 parser: support numbered parameters when used as a singleton 2024-11-13 00:22:49 +09:00
Yukihiro "Matz" Matsumoto 13acf12df5 test/t/vformat.rb: fix encoding error; should have been UTF-8 2024-11-11 23:52:58 +09:00
Yukihiro "Matz" Matsumoto 5387b74be7 hash.c (mrb_hash_to_s): put spaces around =>
CRuby 3.4 puts spaces around `=>` since for example `{:a!=>2}` can be
confusing where to separate tokens.  mruby should follow the behavior.

Many tests in `test/t` directory assumed no spaces around `=>`, so we
needed to fix them too.
2024-11-11 11:07:43 +09:00
dearblue c654123561 Distinguish the call frame of the generator with OP_RETURN_BLK
When multiple identical proc objects are placed on the call stack, it is not possible to distinguish where to `return`.
Therefore, use env object comparisons to do this.

fixed #6411
2024-11-10 18:39:00 +09:00
Yukihiro "Matz" Matsumoto e8bb03da40 numeric.rb (step): iterate over integers even if end is a float
It used to check all `start`, `end` and `step`. If either of them are
float number, `#step` iterated over float number. Now we don't check the
type of `end` argument.
2024-08-03 13:35:09 +09:00
Yukihiro "Matz" Matsumoto 313c5a31ac test/hash.rb: add tests for Hash#assoc and Hash#rassoc 2024-07-18 15:09:49 +09:00