Commit graph

20692 commits

Author SHA1 Message Date
Nobuyoshi Nakada
1c15f641cc [Bug #20929] Win32: Encode timezone name in UTF-8 2024-12-06 18:59:38 +09:00
Nobuyoshi Nakada
78762b5218 [Bug #20929] Fix assert_zone_encoding
The default internal encoding is not taken into account to encode
timezone name.
2024-12-06 18:59:38 +09:00
tomoya ishida
5f65321915 [ruby/reline] Combine MAPPINGS(single byte input to symbol) with
key_bindings(escape sequence to symbol)
(https://github.com/ruby/reline/pull/715)

6a7e249374
2024-12-06 07:09:24 +00:00
Matt Valentine-House
d4fb966186 [ruby/mmtk] Add MMTk test exclusions for Ruby CI
f62e5803f1
2024-12-05 20:12:45 +00:00
Aaron Patterson
6877c38866 [ruby/prism] Fix error messages for unterminated ( and {
If we hit an EOF token, and the character before the EOF is a newline,
we should make EOF token start at the previous newline.  That way any
errors reported will occur on that line.

For example "foo(\n" should report an error on line 1 even though the
EOF technically occurs on line 2.

[Bug #20918]
https://bugs.ruby-lang.org/issues/20918

60bc43de8e
2024-12-05 18:42:01 +00:00
Peter Zhu
ce1ad1b816 Standardize on the name "modular GC"
We have name fragmentation for this feature, including "shared GC",
"modular GC", and "external GC". This commit standardizes the feature
name to "modular GC" and the implementation to "GC library".
2024-12-05 10:33:26 -05:00
Stan Lo
26ab20fec1 [ruby/rdoc] Workaround JRuby's jar-dependencies error and test
failures on CI
(https://github.com/ruby/rdoc/pull/1225)

* Workaround JRuby's jar-dependencies error on CI

* Skip problematic encoding test for JRuby

3f9897d64c
2024-12-05 12:31:51 +00:00
Stan Lo
2ecd2fe0ed [ruby/rdoc] Deprecate main and title directives
(https://github.com/ruby/rdoc/pull/1218)

* Deprecate :main: directive

* Deprecate :title: direcive

* Update documentation

* Remove :main: directive's usage

* Update test cases

* Add '.rdoc_options' to suggested alternatives

e2d4ac9dad
2024-12-05 11:36:34 +00:00
Jean Boussier
1510d72bec [ruby/json] Fix generate(script_safe: true) to not confuse unrelated characters
Fix: https://github.com/ruby/json/issues/715

The first byte check was missing.

93a7f8717d
2024-12-05 09:16:22 +01:00
Nobuyoshi Nakada
3b27818062 [ruby/shellwords] NUL char cannot be in shell words
2c7ae1b76c
2024-12-04 07:48:59 +00:00
Nobuyoshi Nakada
edd3977b40 [ruby/logger] Enable log file rotation on Windows
Since ruby 2.3, a file opened with `File::SHARE_DELETE` and
`File::BINARY` can be renamed or removed.

7b6146fee6
2024-12-04 07:45:39 +00:00
tomoya ishida
e539342f65 [ruby/irb] Don't show 'Maybe IRB bug!' in show_source and ls command
(https://github.com/ruby/irb/pull/1039)

9eb14a3a0b
2024-12-03 21:55:33 +00:00
CosmicOppai
e97225b182 [ruby/timeout] updated tests
c6d121aa18
2024-12-03 06:49:56 +00:00
CosmicOppai
e7dd185e21 [ruby/timeout] refactor the change to raise for nil and type-errror and added tests
ffc8d7c003
2024-12-03 06:49:55 +00:00
CosmicOppai
0839eae2d3 [ruby/timeout] refactor the change to keep the compatability with nil and type-errror and added tests
e8a7dbdb87
2024-12-03 06:49:54 +00:00
CosmicOppai
0f2cd39e68 [ruby/timeout] refactor the change to keep the compatability with nil and type-errror and added tests
8342544979
2024-12-03 06:49:54 +00:00
Hiroshi SHIBATA
d85e8b5339 Reapply "[ruby/rdoc] fix: C variables should never show up in Ancestors tree"
This reverts commit 0fe82ae087.
2024-12-03 10:59:32 +09:00
Mike Dalessio
4cce246d86 [ruby/rdoc] ClassModule#superclass= accepts a ClassModule as an
argument
(https://github.com/ruby/rdoc/pull/1222)

It is necessary for ClassModule's instance variable @superclass to
always be a String (or nil) so that the class can be saved with
`#marshal_dump` and loaded with `#marshal_load`.

However, there's no type checking being done, which allows a bug like
the one reported in #1221 (which was introduced in #1217) that sets
superclass to a ClassModule. That bug requires:

- setting a superclass to a NormalClass
- marshal_save
- marshal_load (which raises an exception)

With this change, passing a ClassModule to ClassModule#superclass= is
explicitly allowed by saving the full name of the ClassModule in the
@superclass instance variable.

9ced6d534c
2024-12-02 22:07:31 +00:00
ydah
fd217d475d [ruby/prism] Reject invalid operator after match predicate or after match required
Partially fixes: #3171

d0d9699c27
2024-12-02 18:42:16 +00:00
ydah
2ba5987263 [ruby/prism] Reject invalid dot method call after match predicate or after match required
Partially fixes:  https://github.com/ruby/prism/issues/3171

5c33fa5a1a
2024-12-02 18:41:38 +00:00
ydah
aa77bfd13e [ruby/prism] Reject extra comma in array after keyword argument
Fixes: https://github.com/ruby/prism/issues/3109

9ed989c30d
2024-12-02 18:39:49 +00:00
tomoya ishida
36aeb12aa9 [ruby/reline] Implement buffered output to Reline::ANSI
(https://github.com/ruby/reline/pull/790)

Minimize the call of STDOUT.write
This will improve rendering performance especially when there is a busy thread `Thread.new{loop{}}`

a6fe45f5ba
2024-12-02 16:44:49 +00:00
Misaki Shioi
8f57204c19
Avoid test failures on hosts that only support IPv4 (#12213)
To verify the behavior of HEv2, some tests were prepared. But unexpected failures occur in certain environments.
This happens in environments where "localhost" resolves only to an IPv4 address during tests that verify connections to IPv6.

For example, the following situation can occur:

- The server process is bound to ::1.
- The client socket always resolves "localhost" to 127.0.0.1 and attempts to connect to 127.0.0.1.
- Since no server is bound to 127.0.0.1, an ECONNREFUSED error is raised.

In such situations, the behavior of `TCPSocket.new` remains unchanged from before the introduction of HEv2.
(The failures occur because tests explicitly binding to ::1 were added to verify HEv2 behavior.)

This change ensures that the affected tests are skipped in environments of this kind.
2024-12-02 21:47:51 +09:00
Nobuyoshi Nakada
8ec58a91f7 [ruby/io-console] Add IO#ttyname that returns the tty name or nil
fdad351501
2024-12-02 08:03:30 +00:00
Hiroshi SHIBATA
165e34ed94 Disabled test_s_random_bytes_is_fork_safe again 2024-12-02 15:32:05 +09:00
Hiroshi SHIBATA
587bd583cc [ruby/securerandom] Enabled test_s_random_bytes_is_fork_safe with Apple Silicon and expand running times
40ddef8a83
2024-12-02 15:32:05 +09:00
Hiroshi SHIBATA
94f8bc95e3 [ruby/securerandom] Enabled test_s_random_bytes_is_fork_safe on GitHub Actions
bb1c078e9f
2024-12-02 15:32:05 +09:00
Hiroshi SHIBATA
eb0442a581 [ruby/securerandom] Removed unnecessary module for SecureRandom tests
da7d324c7d
2024-12-02 15:32:05 +09:00
Sutou Kouhei
9a7f050eda [ruby/strscan] test: don't omit "(...)" for method calls that have at least one argument
dddae9c99a
2024-12-02 10:50:34 +09:00
Jean Boussier
79cc3d26ed StringScanner#scan_integer support base 16 integers (#116)
Followup: https://github.com/ruby/strscan/pull/115

`scan_integer` is now implemented in Ruby as to efficiently handle
keyword arguments without allocating a Hash. Given the goal of
`scan_integer` is to more effciently parse integers without having to
allocate an intermediary object, using `rb_scan_args` would defeat the
purpose.

Additionally, the C implementation now uses `rb_isdigit` and
`rb_isxdigit`, because on Windows `isdigit` is locale dependent.
2024-12-02 10:50:34 +09:00
Yusuke Endoh
5514485e13 [ruby/strscan] Prevent a warning "ambiguous first argument" during a
test
(https://github.com/ruby/strscan/pull/118)

20241128T153002Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20241128T153002Z/ruby/test/strscan/test_stringscanner.rb:908: warning: ambiguous first argument; put parentheses or a space even after `-` operator
```

af3fd2f045
2024-12-02 10:50:34 +09:00
Hiroshi SHIBATA
0fe82ae087
Revert "[ruby/rdoc] fix: C variables should never show up in Ancestors tree"
This reverts commit 2923f42ed7.

3375565361 (step):23:1031

```
/home/runner/work/actions/actions/snapshot-master/lib/rdoc/code_object.rb:322:in 'RDoc::CodeObject#parent': undefined method 'find_class_or_module' for nil (NoMethodError)
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/code_object/class_module.rb:342:in 'RDoc::ClassModule#marshal_dump'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/store.rb:878:in 'Marshal.dump'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/store.rb:878:in 'block in RDoc::Store#save_class'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/store.rb:877:in 'IO.open'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/store.rb:877:in 'RDoc::Store#save_class'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/store.rb:763:in 'block in RDoc::Store#save'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/store.rb:762:in 'Array#each'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/store.rb:762:in 'RDoc::Store#save'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/generator/ri.rb:27:in 'RDoc::Generator::RI#generate'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/rdoc.rb:528:in 'block in RDoc::RDoc#generate'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/rdoc.rb:522:in 'Dir.chdir'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/rdoc.rb:522:in 'RDoc::RDoc#generate'
	from /home/runner/work/actions/actions/snapshot-master/lib/rdoc/rdoc.rb:501:in 'RDoc::RDoc#document'
	from ./tool/rdoc-srcdir:27:in '<main>'
```
2024-12-02 09:39:56 +09:00
Kouhei Yanagita
ae59b44041 [ruby/set] Fix ^ to respect subclasses
f88ecdef6b
2024-12-02 08:28:58 +09:00
tomoya ishida
0fc70022e6 [ruby/reline] Call user defined sigwinch and sigcont handler
(https://github.com/ruby/reline/pull/788)

7d44770c84
2024-11-30 17:21:20 +00:00
Mike Dalessio
83bd9191d8 [ruby/rdoc] Methods are sorted symbols-first
(https://github.com/ruby/rdoc/pull/1219)

There are three distinct ranges of symbols in ASCII:

- the range below "A", 0..64 in decimal
- the range between "Z" and "a", 91..96 in decimal
- the range above "z", 123..127 in decimal

With this change, any method starting with a character in these
"symbol ranges" will be sorted before a method starting with an alpha
ASCII character. The remaining methods, all starting with alpha or
8-bit characters, will be sorted against each other exactly as before.

Specifically this addresses the issue from #1204 which is that `#[]`
and `#^` were previously sorted _after_ the alpha methods. These
methods will now be sorted before alpha methods.

Fixes https://github.com/ruby/rdoc/pull/1204

a4f13d242b
2024-11-30 16:06:54 +00:00
Pascal Terjan
da03ab62e6 [ruby/reline] Fix tests failing when INPUTRC is defined
(https://github.com/ruby/reline/pull/789)

Failure: test_empty_xdg_config_home(Reline::Config::Test)
/home/pterjan/reline/test/reline/test_config.rb:563:in `test_empty_xdg_config_home'
     560:     expected = File.expand_path('~/.config/readline/inputrc')
     561:     FileUtils.mkdir_p(File.dirname(expected))
     562:     FileUtils.touch(expected)
  => 563:     assert_equal expected, @config.inputrc_path
     564:   ensure
     565:     FileUtils.rm(expected)
     566:     ENV['XDG_CONFIG_HOME'] = xdg_config_home_backup
<"/tmp/test_reline_config_4131165/.config/readline/inputrc"> expected but was
<"/etc/inputrc">

7de5a50f63
2024-11-30 14:42:31 +00:00
Mike Dalessio
2923f42ed7 [ruby/rdoc] fix: C variables should never show up in Ancestors tree
(https://github.com/ruby/rdoc/pull/1217)

If a NormalClass's superclass is a C enclosure, then update the
superclass to point to the RDoc::NormalClass.

This is done in a single pass after all files have been parsed.

Fixes https://github.com/ruby/rdoc/pull/1205.

1ecd9581b1
2024-11-30 12:31:42 +00:00
John Hawthorn
f1dda5ed01 Warn when redefining __id__ as well as object_id
[Feature #20912]
2024-11-29 20:41:00 -08:00
viralpraxis
660b995365 [Bug #20915] Fix SEGV with TracePoint#parameters and aliased C method
The following snippet results with a SEGV:

```ruby
C = Class.new do
  alias_method :new_to_s, :to_s
end

TracePoint.new(:c_call, &:parameters).enable { C.new.new_to_s }
```

at MRI 3.3.6 and ruby 3.4.0dev

The root cause of the issue lies in the `rb_tracearg_parameters` function
within the `RUBY_EVENT_C_RETURN` branch. Specifically, when the invoked
method is an alias for a C function,
`rb_method_entry_without_refinements(..., trace_arg->called_id, ...)`
may return NULL. In that case we can fallback to `trace_arg->id`.
2024-11-29 18:42:48 -05:00
Durable Programming Team
36a98307aa [rubygems/rubygems] make pretty_print tests whitespace agnostic
23e9396d22
2024-11-29 19:29:15 +00:00
Mari Imaizumi
c06dcba964 [ruby/reline] Fix RELINE_TEST_ENCODING
(https://github.com/ruby/reline/pull/743)

* Fix RELINE_TEST_ENCODING

It was not working because it was not environment variable.

* Fix Encoding::CompatibilityError: Shift_JIS is not compatible with UTF-8

Error: test_completion_append_character(Reline::KeyActor::EmacsTest): Encoding::CompatibilityError: Shift_JIS is not compatible with UTF-8
/home/runner/work/reline/reline/lib/reline/line_editor.rb:814:in 'block in Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Array#select'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:831:in 'Reline::LineEditor#perform_completion'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1434:in 'Reline::LineEditor#complete'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Method#call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Reline::LineEditor#wrap_method_call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1029:in 'block in Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:932:in 'Reline::LineEditor#run_for_operators'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1028:in 'Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1051:in 'Reline::LineEditor#normal_char'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1089:in 'Reline::LineEditor#input_key'
/home/runner/work/reline/reline/test/reline/helper.rb:124:in 'block in Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Array#each'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/test_key_actor_emacs.rb:948:in 'Reline::KeyActor::EmacsTest#test_completion_append_character'
===============================================================================
===============================================================================
Error: test_continuous_completion_disabled_with_perfect_match(Reline::KeyActor::EmacsTest): Encoding::CompatibilityError: Shift_JIS is not compatible with UTF-8
/home/runner/work/reline/reline/lib/reline/line_editor.rb:814:in 'block in Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Array#select'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:831:in 'Reline::LineEditor#perform_completion'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1434:in 'Reline::LineEditor#complete'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Method#call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Reline::LineEditor#wrap_method_call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1029:in 'block in Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:932:in 'Reline::LineEditor#run_for_operators'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1028:in 'Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1051:in 'Reline::LineEditor#normal_char'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1089:in 'Reline::LineEditor#input_key'
/home/runner/work/reline/reline/test/reline/helper.rb:124:in 'block in Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Array#each'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/test_key_actor_emacs.rb:936:in 'Reline::KeyActor::EmacsTest#test_continuous_completion_disabled_with_perfect_match'
===============================================================================
===============================================================================
Error: test_continuous_completion_with_perfect_match(Reline::KeyActor::EmacsTest): Encoding::CompatibilityError: Shift_JIS is not compatible with UTF-8
/home/runner/work/reline/reline/lib/reline/line_editor.rb:814:in 'block in Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Array#select'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:808:in 'Reline::LineEditor#filter_normalize_candidates'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:831:in 'Reline::LineEditor#perform_completion'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1434:in 'Reline::LineEditor#complete'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Method#call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:961:in 'Reline::LineEditor#wrap_method_call'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1029:in 'block in Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:932:in 'Reline::LineEditor#run_for_operators'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1028:in 'Reline::LineEditor#process_key'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1051:in 'Reline::LineEditor#normal_char'
/home/runner/work/reline/reline/lib/reline/line_editor.rb:1089:in 'Reline::LineEditor#input_key'
/home/runner/work/reline/reline/test/reline/helper.rb:124:in 'block in Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Array#each'
/home/runner/work/reline/reline/test/reline/helper.rb:117:in 'Reline::TestCase#input_keys'
/home/runner/work/reline/reline/test/reline/test_key_actor_emacs.rb:924:in 'Reline::KeyActor::EmacsTest#test_continuous_completion_with_perfect_match'
===============================================================================
Finished in 2.118582151 seconds.
385 tests, 1762 assertions, 0 failures, 3 errors, 0 pendings, 3 omissions, 0 notifications

4df825c48f
2024-11-29 18:15:46 +00:00
Yusuke Endoh
50a34637a4 Avoid illegal pointer
When loading a crafted marshal data of Random, a pointer to an illegal
address was created. I don't think there is any harm since the data is
normalized before access, but just to be safe, I add a check to make it
an error.
2024-11-29 03:01:46 +09:00
tomoya ishida
33c6bbca22 [ruby/reline] fix/omit test that fail in encoding=US_ASCII
(https://github.com/ruby/reline/pull/784)

a6d1ac54e6
2024-11-27 18:36:57 +00:00
Jean Boussier
d5de1a5789 [ruby/strscan] Implement #scan_integer to efficiently parse Integer
(https://github.com/ruby/strscan/pull/115)

Fix: https://github.com/ruby/strscan/issues/113

This allows to directly parse an Integer from a String without needing
to first allocate a sub string.

Notes:

The implementation is limited by design, it's meant as a first step,
only the most straightforward, based 10 integers are supported.

6a3c74b4c8
2024-11-27 09:24:07 +09:00
Ellen Marie Dash
092a48de7e [rubygems/rubygems] [SpecFetcher] If candidates include {name}-ruby or ruby-{name}, recommend those.
d7d33172c1
2024-11-26 22:04:26 +00:00
Randy Stauner
1dd40ec18a
Optimize instructions when creating an array just to call include? (#12123)
* Add opt_duparray_send insn to skip the allocation on `#include?`

If the method isn't going to modify the array we don't need to copy it.
This avoids the allocation / array copy for things like `[:a, :b].include?(x)`.

This adds a BOP for include? and tracks redefinition for it on Array.

Co-authored-by: Andrew Novoselac <andrew.novoselac@shopify.com>

* YJIT: Implement opt_duparray_send include_p

Co-authored-by: Andrew Novoselac <andrew.novoselac@shopify.com>

* Update opt_newarray_send to support simple forms of include?(arg)

Similar to opt_duparray_send but for non-static arrays.

* YJIT: Implement opt_newarray_send include_p

---------

Co-authored-by: Andrew Novoselac <andrew.novoselac@shopify.com>
2024-11-26 14:31:08 -05:00
tomoya ishida
c1dcd1d496 [ruby/reline] KeyStroke handles multibyte character
(https://github.com/ruby/reline/pull/713)

5a8da85f2b
2024-11-26 17:58:43 +00:00
tomoya ishida
def684508c [ruby/irb] Fix indentation of xstring literal
(https://github.com/ruby/irb/pull/1038)

Fixes indent calculation of this input
```
if false
p `ls`
end
```

4217a46f5d
2024-11-26 17:50:30 +00:00
Yusuke Endoh
16d98dc3c1 [ruby/uri] Suppress deprecate warning of test class (retry)
(https://github.com/ruby/uri/pull/140)

A follow-up to bd2e4be9d0

Also, leave a comment that the use of `URI::REGEXP` is intentional

bdf765e44a
2024-11-26 10:02:58 +00:00
Jean Boussier
693a793521 JSON::GeneratorError expose invalid object
Fix: https://github.com/ruby/json/issues/710

Makes it easier to debug why a given tree of objects can't
be dumped as JSON.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-11-26 15:11:05 +09:00