Commit Graph

13605 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto f906ac314c Merge pull request #5651 from dearblue/doc3.1
Update `doc/mruby3.1.md`
2022-02-19 15:49:44 +09:00
dearblue 401d316bcf Update doc/mruby3.1.md
- `OP_GETIDX`, `OP_SETIDX` : Fix operand number
- `OP_SYMBOL` : Add entry
2022-02-19 14:39:17 +09:00
Yukihiro "Matz" Matsumoto 5a014997ef Merge pull request #5650 from dearblue/keywords
Insert an empty hash before the first `NODE_KW_REST_ARGS`
2022-02-19 10:25:11 +09:00
dearblue 12d51807a3 Insert an empty hash before the first NODE_KW_REST_ARGS
I expect this will fix the two problems that "#5640" didn't address.

- It is expected to raise an exception `TypeError`, but it didn't before.

  ```console
  % bin/mruby -e 'p [**1]'
  [1]
  ```

- The variable `h` is expected to keep an empty hash, but it didn't before.

  ```console
  % bin/mruby -e 'h = {}; p(**h, a: 1, b: 2); p h'
  {:a=>1, :b=>2}
  {:a=>1, :b=>2}
  ```
2022-02-18 22:15:50 +09:00
Yukihiro "Matz" Matsumoto 47068ae07a vm.c: packed arguments length may be zero for send method. 2022-02-18 14:38:07 +09:00
Yukihiro "Matz" Matsumoto 1e314242e4 Merge pull request #5648 from mruby/dependabot/github_actions/github/super-linter-4.9.0
build(deps): bump github/super-linter from 4.8.7 to 4.9.0
2022-02-17 13:07:27 +09:00
dependabot[bot] 90e61e6a26 build(deps): bump github/super-linter from 4.8.7 to 4.9.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.7 to 4.9.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.8.7...v4.9.0)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-16 14:05:48 +00:00
Yukihiro "Matz" Matsumoto a8f0e79107 parse.y: revert 9e064f2; fix #5647
Need to declare unnamed parameter when argument decomposition used.
2022-02-16 13:56:10 +09:00
Yukihiro "Matz" Matsumoto 1e0bdea30b codedump.c: print implicit operand of OP_HASHCAT.
Just like `OP_ARYCAT` and `OP_STRCAT`.
2022-02-16 07:40:42 +09:00
Yukihiro "Matz" Matsumoto ff3a5ebed6 vm.c: should check type before hash access.
Since the operand of double splat (`**`) may not be a hash, simple
assertion (previous code since d42a64e) was not enough for this case.
2022-02-15 18:36:38 +09:00
Yukihiro "Matz" Matsumoto ecb28f4bf4 load.c: add data boundary check for broken compiled binary. 2022-02-14 17:34:28 +09:00
Yukihiro "Matz" Matsumoto aba3d427c7 state.c: reps may be NULL if a broken compiled binary given. 2022-02-14 17:34:27 +09:00
Yukihiro "Matz" Matsumoto e884236e1c dump.h, irep.h: update comments not to omit buffer length for loading. [ci skip] 2022-02-14 17:34:27 +09:00
Yukihiro "Matz" Matsumoto ad3ce7b41c Merge pull request #5642 from dearblue/errmesg
Avoid direct access to error messages as instance variables
2022-02-13 20:59:47 +09:00
Yukihiro "Matz" Matsumoto 38b164ace7 codegen.c: fix a bug in gen_values().
- Fix limit handling that fails 15 arguments method calls.
- Fix too early argument packing in arrays.
2022-02-12 12:39:35 +09:00
Yukihiro "Matz" Matsumoto 0ed3fcfa26 Merge pull request #5646 from koic/support_array_join_with_string_argument
Make `Array#*` the CRuby compatible behavior when giving a string argument
2022-02-11 15:21:01 +09:00
Yukihiro "Matz" Matsumoto 11e7ca5db9 Merge pull request #5645 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2022-02-10 11:31:01 +09:00
Yukihiro "Matz" Matsumoto fb82108acb load.c: should check if length of irep sections are valid. 2022-02-10 11:25:45 +09:00
Yukihiro "Matz" Matsumoto d912b864df mruby-range-ext/range.c: cover? should work with begin-less ranges. 2022-02-09 13:32:20 +09:00
Yukihiro "Matz" Matsumoto 4e8ab145da vm.c: adjust integer types. 2022-02-08 13:11:44 +09:00
Yukihiro "Matz" Matsumoto 9037e447a5 numeric.c: avoid implicit cast from integer to double. 2022-02-08 13:11:44 +09:00
Yukihiro "Matz" Matsumoto 4562ba14c0 codegen.c: limit check was too restrictive in gen_values().
That can create unnecessary arrays when more than 12 arguments are
given to a method.
2022-02-08 13:11:43 +09:00
Yukihiro "Matz" Matsumoto 0849a2885f codegen.c: stack position may be wrong on assignments.
When `[]=` access includes keyword arguments.
2022-02-08 13:11:43 +09:00
Yukihiro "Matz" Matsumoto 4c13188ea6 codegen.c: generate OP_HASH in gen_hash() if limit exceeds.
That means when `limit` is `0` it should always generate a hash.
2022-02-08 13:11:43 +09:00
Yukihiro "Matz" Matsumoto 6f5e74f576 codegen.c: change size_t to uint16_t To remove type conversion warnings. 2022-02-08 13:11:42 +09:00
Koichi ITO 182096d8c0 Make Array#* the CRuby compatible behavior when giving a string argument
## Summary

This following is a behavior from CRuby 1.8.7 to 3.1.0.

```console
% ruby -ve "p ['a', 'b', 'c']*''"
ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin13.0.2]
"abc"

% ruby -ve "p ['a', 'b', 'c']*''"
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin19]
"abc"
```

### Before (mruby 3.0.0)

mruby unexpectedly gives the TypeError.

```ruby
['a', 'b', 'c']*'' #=> String cannot be converted to Integer (TypeError)
```

### After

This PR makes mruby behave compatible with CRuby.

```ruby
['a', 'b', 'c']*'' #=> 'abc'
```

As far as I checked, the behavior is unspecified when `Array#*`'s argument
is not an instance of Integer class in X 3017 : 2013 (ISO/IEC 30170 : 2012).

## Additional Information

I noticed this difference by the following idiom when writing ASCII art code
using Ruby.

```ruby
%w(foo bar baz)*''
```

e.g. TRICK (https://github.com/tric)
2022-02-08 11:20:14 +09:00
John Bampton 4f986060c0 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2022-02-07 19:52:12 +10:00
Yukihiro "Matz" Matsumoto 6cc6d9b078 Merge pull request #5644 from dearblue/errno-nopresym
Support `disable_presym` for `mrbgems/mruby-errno`
2022-02-07 16:05:22 +09:00
Yukihiro "Matz" Matsumoto 8b32a1f7ae Merge pull request #5643 from dearblue/errno-nostdio
Support `MRB_NO_STDIO` for `mrbgems/mruby-errno`
2022-02-07 15:43:51 +09:00
Yukihiro "Matz" Matsumoto e24e81cd3c mruby.c: rindex() is not supported by VC. 2022-02-06 22:44:02 +09:00
Yukihiro "Matz" Matsumoto d42a64eadf vm.c: add assertion for type of register values.
We used to check them by `mrb_ensure_xxx_type()` functions, but type
errors there should not occur if there's no bug in code generations.
So we use assertion rather than dynamic type checks.
2022-02-06 22:17:53 +09:00
Yukihiro "Matz" Matsumoto cf00c32e3a mruby.c: -b option should only affects the script.
Not the libraries loaded by `-r`. Instead, `.mrb` extension in the path
should determine whether they are compiled binary.
2022-02-06 22:17:41 +09:00
Yukihiro "Matz" Matsumoto bf8e061c17 Merge pull request #5641 from dearblue/ci-win2022
Pinning the Visual Studio version in GitHub Actions
2022-02-06 20:49:53 +09:00
dearblue 0a4f21c60f Support disable_presym for mrbgems/mruby-errno
The `mrbgems/mruby-errno/src/known_errors_def.cstub` file has been extended, so the `mrbgems/mruby-errno/src/known_errors_e2c.cstub` file is no longer needed.
2022-02-06 18:39:46 +09:00
dearblue a82220211d Support MRB_NO_STDIO for mrbgems/mruby-errno 2022-02-06 16:12:41 +09:00
dearblue d6773cbd71 Avoid direct access to error messages as instance variables
ref. #2485

The `SystemCallError#to_s` method also needed to be modified, but since it has no functional difference from the `Exception#to_s` method, it will be removed.
2022-02-06 15:45:13 +09:00
dearblue faffc0c4d3 Pinning the Visual Studio version in GitHub Actions
Until now, `windows-latest` meant `windows-2019`, but now it seems that it is being replaced by `windows-2022` in stages.
At the same time, Visual Studio 2019 will be replaced by Visual Studio 2022.

Since mruby's CI is configured to assume Visual Studio 2019, we'll update this and explicitly specify `windows-2022`.
2022-02-05 21:42:54 +09:00
Yukihiro "Matz" Matsumoto b7adf61fe2 Merge pull request #5640 from dearblue/rest-keywords
Check the type of the keyword rest argument
2022-02-05 18:30:58 +09:00
dearblue 6dfc47f5d4 Check the type of the keyword rest argument
If a non-hash object is passed in `OP_SEND` and `OP_SUPER`, an error should occur.

```ruby
kwd = "string"
p(**kwd)  #  => expect raised TypeError
```
2022-02-05 17:41:01 +09:00
dearblue d0e8637e30 Integrate argument normalization for OP_SEND and OP_SUPER 2022-02-05 17:36:23 +09:00
Yukihiro "Matz" Matsumoto 903c5f978a vm.c: check object type before concatenating strings. 2022-02-03 10:41:09 +09:00
Yukihiro "Matz" Matsumoto ae3c99767a codegen.c: fixed a bug in hash code generation with !val. 2022-02-03 10:40:05 +09:00
Yukihiro "Matz" Matsumoto 8d06e79c57 codedump.c: remove unnecessary condition.
`(irep->pool[b].tt & IREP_TT_NFLAG) == 0` is always true ensured by
the assertion.
2022-02-02 20:57:43 +09:00
Yukihiro "Matz" Matsumoto f9f2d4c4e3 codedump.c: adjust OP_HASHCAT variable label position. 2022-02-02 20:51:37 +09:00
Yukihiro "Matz" Matsumoto f0af96c130 mruby-class-ext: add Class#subclasses method. 2022-02-01 22:37:49 +09:00
Yukihiro "Matz" Matsumoto d9bf7982e9 class.c: set MRB_FL_CLASS_IS_INHERITED flag for bootstrapped classes. 2022-02-01 22:36:42 +09:00
Yukihiro "Matz" Matsumoto 00f2b74ab2 kernel.c, binding.c: use MRB_SYM() instead of mrb_intern_lit(). 2022-01-31 16:20:52 +09:00
Yukihiro "Matz" Matsumoto 92fb6d3526 Merge pull request #5639 from suetanvil-misc/project-mruby-errno-readme
Updated mruby-errno/README.md to pass the lint checks.
2022-01-31 15:45:18 +09:00
Yukihiro "Matz" Matsumoto 8252352d7b parse.y: fix buffer overflow with tweaked mruby binary. 2022-01-31 15:42:52 +09:00
Chris Reuter 198e10473b Updated mruby-errno/README.md to pass the lint checks. 2022-01-29 18:40:05 -05:00