Граф коммитов

18240 Коммитов

Автор SHA1 Сообщение Дата
Hiroshi SHIBATA edadd5b796 [ruby/psych] Typofix by misspell
https://github.com/ruby/psych/commit/fc9ca15999
2023-12-25 21:12:49 +09:00
dependabot[bot] 12ff13c6e4 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.83 to 0.9.84.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.83...v0.9.84)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

https://github.com/rubygems/rubygems/commit/ec4672c3e7
2023-12-25 21:12:49 +09:00
Nobuyoshi Nakada e324953090 [ruby/rdoc] Fix support for `rb_file_const` and `rb_curses_define_const`
Constant definitions using these functions have been supported, but
since RDoc::Parser::C#gen_const_table did not consider other than
`rb_define_const` the documents for them have not been found, without
`Document-const` direvtive.

Fixes https://github.com/ruby/rdoc/issues/1067

https://github.com/ruby/rdoc/commit/cdad51a60b
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA fa251d60aa Revert "Revert all of commits after Prism 0.19.0 release"
This reverts commit d242e8416e.
2023-12-25 21:12:49 +09:00
Nobuyoshi Nakada 596db9c1f4 [Feature #19370] Blocks without anonymous parameters should not affect 2023-12-25 18:28:21 +09:00
Takashi Kokubun 44592c4e20
Implement `it` (#9199)
[[Feature #18980]](https://bugs.ruby-lang.org/issues/18980)

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
2023-12-25 01:15:41 -08:00
Nobuyoshi Nakada a9f0961831 [Feature #19370] Prohibit nesting anonymous parameter forwarding 2023-12-25 14:44:04 +09:00
Nobuyoshi Nakada 2cdbeb29e6
Do not leave test file
Run this test separately because something seems remained unreleased
on Windows.
2023-12-25 13:01:55 +09:00
Peter Zhu b4efa4b700 Don't copy RUBY_FL_PROMOTED flag in rb_obj_setup
RUBY_FL_PROMOTED is used by the garbage collector to track when an
object becomes promoted to the old generation. rb_obj_setup must not
copy that flag over because then it may become out-of-sync with the age
of the object.

This fixes a bug in Method#clone where the cloned Method object may get
RUBY_FL_PROMOTED incorrectly set.
2023-12-24 22:13:49 -05:00
Hiroshi SHIBATA 27ead9907d
Typofix under lib and test, tool directories 2023-12-25 11:32:42 +09:00
Peter Zhu 7002e77694 Fix Symbol#inspect for GC compaction
The test fails when RGENGC_CHECK_MODE is turned on:

    1) Failure:
    TestSymbol#test_inspect_under_gc_compact_stress [test/ruby/test_symbol.rb:123]:
    <":testing"> expected but was
    <":\x00\x00\x00\x00\x00\x00\x00">.
2023-12-24 21:29:40 -05:00
Peter Zhu 70618a48f7 Fix off-by-one error for declarative marking
The for loops for marking and reference updating declaratively marked
TypedData objects did not mark/reference update the very last element.

When RGENGC_CHECK_MODE is turned on, this caused the test in Enumerator
to fail with:

    tool/lib/test/unit/testcase.rb:173:in `rescue in run': failed to allocate memory (NoMemoryError)
2023-12-24 20:37:59 -05:00
Samuel Williams 260bf60e52
Correctly release the underlying file mapping. (#9340)
* Avoiding using `Tempfile` which was retaining the file preventing it from unlinking.
2023-12-25 14:20:53 +13:00
Peter Zhu 5af64ff7db Fix Enumerator#with_index for GC compaction
enumerator_block_call was not safe for compaction because the Array
backing the argv was not pinned, so it could get moved during compaction
which would make argv point to somewhere else.

The test crashes when RGENGC_CHECK_MODE is turned on:

    TestEnumerator#test_with_index_under_gc_compact_stress
    check_rvalue_consistency: 0x55db0b399450 is not a Ruby object.
    test/ruby/test_enumerator.rb:133: [BUG] check_rvalue_consistency_force: there is 1 errors.
    ruby 3.3.0dev (2023-12-23T23:00:27Z master 50bf437341) [x86_64-linux]
    -- Control frame information -----------------------------------------------
    c:0034 p:---- s:0192 e:000187 CFUNC  :with_index
    c:0033 p:---- s:0185 e:000184 CFUNC  :each
    c:0032 p:---- s:0182 e:000181 CFUNC  :to_a
    c:0031 p:0055 s:0178 e:000175 BLOCK  test/ruby/test_enumerator.rb:133
    c:0030 p:0024 s:0172 e:000171 METHOD tool/lib/envutil.rb:242
    c:0029 p:0024 s:0167 e:000166 METHOD tool/lib/envutil.rb:251
    c:0028 p:0005 s:0160 e:000159 METHOD test/ruby/test_enumerator.rb:131
    ...
    -- C level backtrace information -------------------------------------------
    build/ruby(rb_print_backtrace+0x14) [0x55db0b1deb21] vm_dump.c:820
    build/ruby(rb_vm_bugreport) vm_dump.c:1151
    build/ruby(bug_report_end+0x0) [0x55db0b3a53a6] error.c:1042
    build/ruby(rb_bug_without_die) error.c:1042
    build/ruby(die+0x0) [0x55db0afc77c2] error.c:1050
    build/ruby(rb_bug) error.c:1052
    build/ruby(gc_move+0x0) [0x55db0afbada0] gc.c:1714
    build/ruby(check_rvalue_consistency+0xa) [0x55db0afef0c3] gc.c:1729
    build/ruby(is_markable_object) gc.c:4769
    build/ruby(gc_mark_stack_values) gc.c:6595
    build/ruby(rb_gc_mark_vm_stack_values) gc.c:6605
    build/ruby(rb_execution_context_mark+0x39) [0x55db0b1d8589] vm.c:3309
    build/ruby(thread_mark+0x15) [0x55db0b1a9805] vm.c:3381
    build/ruby(gc_mark_stacked_objects+0x6d) [0x55db0aff2c3d] gc.c:7564
    build/ruby(gc_mark_stacked_objects_all) gc.c:7602
    build/ruby(gc_marks_rest) gc.c:8797
    build/ruby(gc_marks+0xd) [0x55db0aff43d5] gc.c:8855
    build/ruby(gc_start) gc.c:9608
    build/ruby(rb_multi_ractor_p+0x0) [0x55db0aff5463] gc.c:9489
    build/ruby(rb_vm_lock_leave) vm_sync.h:92
    build/ruby(garbage_collect) gc.c:9491
    build/ruby(newobj_slowpath+0xcb) [0x55db0aff57ab] gc.c:2871
    build/ruby(newobj_slowpath_wb_protected) gc.c:2895
    build/ruby(newobj_of0+0x24) [0x55db0aff59e4] gc.c:2937
    build/ruby(newobj_of) gc.c:2947
    build/ruby(rb_wb_protected_newobj_of) gc.c:2962
    build/ruby(ary_alloc_embed+0x10) [0x55db0b2f3e40] array.c:668
    build/ruby(ary_new) array.c:709
    build/ruby(rb_ary_tmp_new_from_values) array.c:759
    build/ruby(rb_ary_new_from_values) array.c:771
    build/ruby(args_copy+0x18) [0x55db0b1bbb88] vm_args.c:158
2023-12-24 16:22:34 -05:00
Peter Zhu f0efeddd41 Fix Regexp#inspect for GC compaction
rb_reg_desc was not safe for GC compaction because it took in the C
string and length but not the backing String object so it get moved
during compaction. This commit changes rb_reg_desc to use the string
from the Regexp object.

The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_inspect_under_gc_compact_stress [test/ruby/test_regexp.rb:474]:
    <"(?-mix:\\/)|"> expected but was
    <"/\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00/">.
2023-12-24 11:04:41 -05:00
Peter Zhu 42442ed789 Fix Regexp#match for GC compaction
The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_match_under_gc_compact_stress:
    NoMethodError: undefined method `match' for nil
        test_regexp.rb:878:in `block in test_match_under_gc_compact_stress'
2023-12-24 09:03:55 -05:00
Samuel Williams 37753f163e
IO::Buffer improvements and documentation. (#9329)
* Restore experimental warnings.

* Documentation and code structure improvements.

* Improved validation of flags, clarified documentation of argument handling.

* Remove inconsistent use of `Example:` and add example to `null?`.

* Expose `IO::Buffer#private?` and add test.
2023-12-25 02:03:36 +13:00
Peter Zhu 50bf437341 Fix String#sub for GC compaction
The test fails when RGENGC_CHECK_MODE is turned on:

    TestString#test_sub_gc_compact_stress = 9.42 s
    1) Failure:
    TestString#test_sub_gc_compact_stress [test/ruby/test_string.rb:2089]:
    <"aaa [amp] yyy"> expected but was
    <"aaa [] yyy">.
2023-12-23 18:00:27 -05:00
Peter Zhu fadda88903 Fix Regexp#to_s for GC compaction
The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_to_s_under_gc_compact_stress = 13.46 s
    1) Failure:
    TestRegexp#test_to_s_under_gc_compact_stress [test/ruby/test_regexp.rb:81]:
    <"(?-mix:abcd\u3042)"> expected but was
    <"(?-mix:\u5C78\u3030\u5C78\u3030\u5C78\u3030\u5C78\u3030\u5C78\u3030)">.
2023-12-23 16:52:05 -05:00
Nobuyoshi Nakada fe9e57bac8
Adjust indent [ci skip] 2023-12-23 19:36:21 +09:00
Hiroshi SHIBATA 7d7a84e99f Merge RubyGems-3.5.3 and Bundler-2.5.3 2023-12-23 09:34:26 +09:00
Koichi Sasada c974ee1abe ensure to restart antoher thread 2023-12-23 05:56:02 +09:00
Kouhei Yanagita e8639098ed [Bug #19977] Fix (nil..nil) === x not to raise TypeError 2023-12-22 16:15:33 +09:00
Takashi Kokubun 9a3c49ee5d RJIT: Convert opt_case_dispatch keys with #to_value
comptime_key is a Ruby object and the value is not valid in machine code.

This PR also implements `CMP r/m64, imm32 (Mod 01: [reg]+disp8)` that is
now needed for running mail.gem benchmark.
2023-12-21 17:47:36 -08:00
Hiroshi SHIBATA 82496f2b38 Merge RubyGems-3.5.2 and Bundler-2.5.2 2023-12-22 07:24:04 +09:00
Peter Zhu e191bf42d2 Fix ary_make_partial_step for compaction
ary could change embeddedness due to compaction, so we should only get
the pointer after allocations.

The included test was crashing with:

    TestArray#test_slice_gc_compact_stress
    ruby/lib/pp.rb:192: [BUG] Segmentation fault at 0x0000000000000038
2023-12-21 10:39:03 -05:00
Stan Lo 2793a30b69 [ruby/irb] Warn users about errors in loading RC files
(https://github.com/ruby/irb/pull/817)

1. Because `IRB.rc_file` always generates an rc file name, even if the
   file doesn't exist, we should check the file exists before trying to
   load it.
2. If any type of errors occur while loading the rc file, we should
   warn the user about it.

https://github.com/ruby/irb/commit/37ffdc6b19
2023-12-20 19:11:01 +09:00
HParker 7ef90b3978 Correct free_on_exit env var to free_at_exit 2023-12-20 14:36:32 +09:00
Takashi Kokubun bd91c5127f
YJIT: Add stats option to RubyVM::YJIT.enable (#9297) 2023-12-19 11:47:27 -08:00
Koichi Sasada f9a48548cf restore the stack pointer on finalizer
When error on finalizer, the exception will be ignored.
To restart the code, we need to restore the stack pointer.

fix [Bug #20042]
2023-12-19 17:59:49 +09:00
Alexander Momchilov b3598f95fa [ruby/psych] Use `assert_same` in tests where applicable
https://github.com/ruby/psych/commit/0dc25a9d6a
2023-12-19 11:07:46 +09:00
Peter Zhu ce436ff3e3 Fix flaky test test_stat_heap
The test sometimes fails with:

    1) Failure:
    TestGc#test_stat_heap [/tmp/ruby/src/trunk-repeat50/test/ruby/test_gc.rb:169]:
    Expected 33434403 to be <= 33434354.
2023-12-18 19:25:37 -05:00
Jean Boussier ba1d1522d3 Make the SHAPE_TOO_COMPLEX performance warning more actionable
As suggested by Mame, we should try to help users fix the issues
without having to lookup the meaning of the warning.
2023-12-18 10:33:18 +01:00
Nobuyoshi Nakada ab7f54688b
Stir the hash value more with encoding index 2023-12-17 00:30:00 +09:00
Nobuyoshi Nakada b710f96b5a
[Bug #20068] Encoding does not matter to empty strings 2023-12-16 16:00:12 +09:00
Hiroshi SHIBATA d242e8416e
Revert all of commits after Prism 0.19.0 release
We should bundle released version of Prism for Ruby 3.3.0
2023-12-16 11:08:51 +08:00
Matt Valentine-House 161787f9be [PRISM] Compile CallTargetNode 2023-12-15 16:15:10 -05:00
Matt Valentine-House 5b6a4d8c12 [PRISM] Compile IndexTargetNode 2023-12-15 16:15:10 -05:00
eileencodes 2e8cfcac91 [ruby/prism] String literal hash keys should be frozen
String literal hash keys can't be mutated by the user so we should mark
them as frozen. We were seeing instructions for hashes with string
literal keys using two `putstring` instructions when it should be a
`putobject` and `putstring`.

Code example:

```ruby
{ "a" => "b" }
```

Instructions before:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,14)>
0000 putobject                              "a"                       (   2)[Li]
0002 putstring                              "b"
0004 newhash                                2
0006 leave
"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)>
0000 putstring                              "a"                       (   1)[Li]
0002 putstring                              "b"
0004 newhash                                2
0006 leave
```

Instructions after:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,14)>
0000 putobject                              "a"                       (   2)[Li]
0002 putstring                              "b"
0004 newhash                                2
0006 leave

"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)>
0000 putobject                              "a"                       (   1)[Li]
0002 putstring                              "b"
0004 newhash                                2
0006 leave
```

https://github.com/ruby/prism/commit/b14ae55385
2023-12-15 20:55:13 +00:00
Ufuk Kayserilioglu 0a31cb1a37 [ruby/prism] Finish keyword hash node flag refactor by renaming flag
https://github.com/ruby/prism/commit/7f812389f8
2023-12-15 18:45:36 +00:00
Kevin Newton b418e5a580 Update error message in test_rubyoptions 2023-12-15 13:42:19 -05:00
HParker 55326a915f Introduce --parser runtime flag
Introduce runtime flag for specifying the parser,

```
ruby --parser=prism
```

also update the description:

```
$ ruby --parser=prism --version
ruby 3.3.0dev (2023-12-08T04:47:14Z add-parser-runtime.. 0616384c9f) +PRISM [x86_64-darwin23]
```

[Bug #20044]
2023-12-15 13:42:19 -05:00
Nobuyoshi Nakada 92b10f5be7 [Bug #20062] Fixed numbered parameter syntax error
At the method definition, the local scope that saves the context of
the numbered parameters needs to be pushed before saving.
2023-12-16 02:11:51 +09:00
eileencodes 049a9bd62f [PRISM] Fix `compile_prism` when src is a file
`compile_prism` can take a source and file (and other arguments) or a
file as the source. `compile` checks if the source is a file and if it
is converts it. `compile_prism` is now doing the same thing.

On the Ruby side `compile` handles a file
[here](https://github.com/ruby/ruby/blob/master/iseq.c#L1159-L1162).

Before:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(26,21)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] name@0
0000 putstring                              "Prism"                   (  25)[Li]
0002 setlocal                               name@0, 0
0005 putself                                                          (  26)[Li]
0006 putobject                              "hello, "
0008 getlocal                               name@0, 0
0011 dup
0012 objtostring                            <calldata!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>
0014 anytostring
0015 concatstrings                          2
0017 send                                   <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, nil
0020 leave
hello, Prism

"********* PRISM *************"
./test.rb:13:in `compile_prism': wrong argument type File (expected String) (TypeError)
	from ./test.rb:13:in `<main>'
make: *** [run] Error 1
```

After:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(26,21)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] name@0
0000 putstring                              "Prism"                   (  25)[Li]
0002 setlocal                               name@0, 0
0005 putself                                                          (  26)[Li]
0006 putobject                              "hello, "
0008 getlocal                               name@0, 0
0011 dup
0012 objtostring                            <calldata!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>
0014 anytostring
0015 concatstrings                          2
0017 send                                   <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, nil
0020 leave

"********* PRISM *************"
== disasm: #<ISeq:<compiled>@test_code.rb:24 (24,0)-(25,21)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] name@0
0000 putstring                              "Prism"                   (  24)[Li]
0002 setlocal                               name@0, 0
0005 putself                                                          (  25)[Li]
0006 putobject                              "hello, "
0008 getlocal                               name@0, 0
0011 dup
0012 objtostring                            <calldata!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>
0014 anytostring
0015 concatstrings                          2
0017 send                                   <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, nil
0020 leave                                                            (  24)
```

Fixes ruby/prism#1609
2023-12-15 10:27:44 -05:00
Kevin Newton f38814564b [ruby/prism] Fix eval parsing depth
https://github.com/ruby/prism/commit/89bf7a4948
2023-12-15 15:19:50 +00:00
Kevin Newton fe9b42f024 [ruby/prism] Invalid pinned locals in pattern matching
https://github.com/ruby/prism/commit/3a67b37a56
2023-12-15 15:03:49 +00:00
TSUYUSATO Kitsune 16830a4783 [ruby/prism] Add an error for `in` keyword in arguments
Fix https://github.com/ruby/prism/pull/2026

https://github.com/ruby/prism/commit/c4b41cd477
2023-12-15 13:25:54 +00:00
Satoshi Tagomori 04f7be6126 loading/testing in different processes for multiple runs 2023-12-15 21:36:27 +09:00
Koichi Sasada 406d4bb599 add a test
proposed at https://bugs.ruby-lang.org/issues/20050#note-5
2023-12-15 11:58:43 +09:00
Jeremy Evans 29e99c84ae Remove unused variables in test_call_op_asgn_keywords_mutable 2023-12-14 18:44:13 -08:00