Commit graph

18546 commits

Author SHA1 Message Date
KJ Tsanaktsidis
9a62fd3cba Fix crash caused by concurrent ObjectSpace.dump_all calls
Since the callback defined in the objspace module might give up the GVL,
we need to make sure the right cr->mfd value is set back after the GVL
is re-obtained.
2023-11-12 17:50:37 +01:00
TSUYUSATO Kitsune
2fb1d37439 [ruby/prism] Reject invalid rational literals like 1e1r on lexing
Fix https://github.com/ruby/prism/pull/1586

b3bde866f2
2023-11-12 02:34:02 +00:00
TSUYUSATO Kitsune
cd91e8e73a [ruby/prism] Introduce non-associativility to in and =>
Fix https://github.com/ruby/prism/pull/1596
Fix https://github.com/ruby/prism/pull/1771
Close https://github.com/ruby/prism/pull/1773

a3413e5605
2023-11-11 20:37:28 +00:00
Nobuyoshi Nakada
9eac9d7178
[Bug #19969] Compact st_table after deleted if possible 2023-11-11 18:49:19 +09:00
Kevin Newton
85db7baccb [ruby/prism] Remove extra locals added by ...
b7850f2d30
2023-11-10 21:50:12 +00:00
Kevin Newton
98e5ea9431 [ruby/prism] Disallow forwarding in blocks
2bbd35943c
2023-11-10 21:50:11 +00:00
Hiroshi SHIBATA
5398bbcbab
Tests of irb is still broken.
Revert "[ruby/irb] Revert "Skip TypeCompletion test in ruby ci"

  This reverts commit 589e2b6782.
2023-11-10 08:29:55 +09:00
Hiroshi SHIBATA
589e2b6782 [ruby/irb] Revert "Skip TypeCompletion test in ruby ci
(https://github.com/ruby/irb/pull/748)"
(https://github.com/ruby/irb/pull/755)

This reverts commit d394af0bbc.

a9d0145115
2023-11-10 07:56:07 +09:00
tomoya ishida
c4efd17061 [ruby/irb] Add command line option to select which completor to use
(https://github.com/ruby/irb/pull/754)

* Add command line option to select which completor to use

* Add test for completor argv

1dec2708c9
2023-11-09 13:15:26 +00:00
Jemma Issroff
ae1fad4cd7 [PRISM] Implement compilation for ForwardingArgumentssNode 2023-11-09 09:45:59 -03:00
Jean Boussier
ea1b1ea1aa String#force_encoding don't clear coderange if encoding is unchanged
Some code out there blind calls `force_encoding` without checking
what the original encoding was, which clears the coderange uselessly.

If the String is big, it can be a rather costly mistake.

For instance the `rack-utf8_sanitizer` gem does this on request
bodies.
2023-11-09 12:38:10 +01:00
TSUYUSATO Kitsune
fae44d6524 [ruby/prism] Reset do_loop_stack around a body of a endless method definition
Fix https://github.com/ruby/prism/pull/1772

cdf58e845e
2023-11-09 08:37:20 +00:00
Yusuke Endoh
486b674e2a Do not allow test-all to load the bundled gems
This change prevents default gems from inadvertently depending on
bundled gems. This issue was discovered by being able to
`require "rbs"` from test/irb.
2023-11-09 14:17:13 +09:00
Vít Ondruch
a168426881
[rubygems/rubygems] Make the test_build_extensions more predictable
The `test_build_extensions` make assumptions about return value of
`Gem.install_extension_in_lib`. Givent that RubyGems allow to override
this method via `defaults.rb` / `operating_system.rb`, this test might
not always pass. This change makes sure that the
`Gem.install_extension_in_lib` is predictable.

e83d0a5da8
2023-11-09 10:34:48 +09:00
Vít Ondruch
5454741712
[rubygems/rubygems] Use extension_in_lib helper instead of custom code
`extension_in_lib` helper improves readibility and it also uses `stub`
on on background instead of custom code.

aacc8ac22c
2023-11-09 10:34:48 +09:00
Kevin Newton
201853f4e1 [ruby/prism] Provide Parameters#signature for mirroring Method#parameters
90b3245528
2023-11-08 22:17:43 +00:00
Jemma Issroff
f9e34a1fd3 [PRISM] Add tests for OptionalKeywordParameterNode
This commit adds tests for the compilation of the
OptionalKeywordParameterNode, and fixes cases on the
RequiredKeywordParameterNode
2023-11-08 18:15:47 -03:00
Jemma Issroff
70e4ff9feb [PRISM] Added tests for ForwardingParameterNode, KeywordRestParameterNode 2023-11-08 18:15:47 -03:00
Jemma Issroff
26cff6ae2b [PRISM] Add tests for several parameters nodes
This commit adds tests for BlockParameterNode, RequiredParameterNode,
RequiredKeywordParameterNode and RestParameterNode
2023-11-08 18:15:47 -03:00
Jeremy Evans
ddd99a5290 [ruby/tempfile] Make Tempfile#open return the underlying File
Add test for this behavior.

0ca31a6b8d
2023-11-08 16:47:29 +00:00
Takashi Kokubun
50402db5a7
YJIT: Disable code GC (#8865)
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
2023-11-08 10:21:04 -05:00
Jeremy Evans
ddcfc9feab [ruby/tempfile] Fix Tempfile#{dup,clone}
Instead of storing the delegate in @tmpfile, use __getobj__, since
delegate library already handles dup/clone for that.  Copy the
unlinked, mode, and opts instance variables to the returned object
when using dup/clone.

Split the close/unlink finalizer into two finalizers. The close
finalizer always closes when any Tempfile instance is GCed, since
each Tempfile instance uses a separate file descriptor. The unlink
finalizer unlinks only when the original and all duped/cloned
Tempfiles are GCed, since all share the same path.

For Tempfile#open, undefine the close finalizer after closing the
current file, the redefine the close finalizer with the new file.

Fixes [Bug #19441]

dafabf9c7b
2023-11-08 15:19:52 +00:00
Adam Hess
f694bd158c Improve error and memory handling
Apply Nobu's suggestions which improve style, memory handling and error correction.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-11-08 08:05:58 -05:00
tomoya ishida
8da33bff8c [ruby/irb] Skip TypeCompletion test in ruby ci
(https://github.com/ruby/irb/pull/748)

d394af0bbc
2023-11-08 06:42:10 +00:00
Yusuke Endoh
7f565b923a Prevent a warning: assigned but unused variable - raised_exception 2023-11-08 15:39:19 +09:00
tomoya ishida
e344010465 [ruby/irb] Type based completion using Prism and RBS
(https://github.com/ruby/irb/pull/708)

* Add completor using prism and rbs

* Add TypeCompletion test

* Switchable completors: RegexpCompletor and TypeCompletion::Completor

* Add completion info to irb_info

* Complete reserved words

* Fix [*] (*) {**} and prism's change of KeywordParameterNode

* Fix require, frozen_string_literal

* Drop prism<=0.16.0 support

* Add Completor.last_completion_error for debug report

* Retrieve `self` and `Module.nesting` in more safe way

* Support BasicObject

* Handle lvar and ivar get exception correctly

* Skip ivar reference test of non-self object in ruby < 3.2

* BaseScope to RootScope, move method objects constant under Methods

* Remove unused Splat struct

* Drop deeply nested array/hash type calculation from actual object. Now, calculation depth is 1

* Refactor loading rbs in test, change preload_in_thread not to cache Thread object

* Use new option added in prism 0.17.1 to parse code with localvars

* Add Prism version check and warn when :type completor cannot be enabled

* build_type_completor should skip truffleruby (because endless method definition is not supported)

1048c7ed7a
2023-11-08 02:46:33 +00:00
Sutou Kouhei
7ed37388fb [ruby/stringio] Add missing row separator encoding conversion
(https://github.com/ruby/stringio/pull/69)

The conversion logic is borrowed from ruby/ruby's io.c:
40391faeab/io.c (L4059-L4079)

Fix ruby/stringio#68

Reported by IWAMOTO Kouichi. Thanks!!!

4b170c1a68
2023-11-08 00:46:17 +00:00
Sutou Kouhei
2a6d6d3d65 [ruby/fiddle] Use Ruby's true/false for C bool
GitHub: fix https://github.com/ruby/fiddle/pull/130

Reported by Benoit Daloze. Thanks!!!

2640e0148e
2023-11-08 09:25:44 +09:00
Jun Aruga
d30ea5831e
CI: Change the openssl_fips.cnf.tmpl and openssl_fips.cnf directories. 2023-11-08 09:25:34 +09:00
Vít Ondruch
ca7444cc44
[rubygems/rubygems] Allow --install-dir to be specified together with --user-install
The combination of `install-dir` and `--user-install` used to be
disabled for no good reason. This even makes problem on Linux
distributions such as Fedora, where `--user-install` is set by default
via operating_system.rb.

The `--install-dir` is already prefered over the `--user-install` by
the implementation, therefore just drop the check.

313b1c5e76
2023-11-08 09:04:28 +09:00
Vít Ondruch
bd5368fdec
[rubygems/rubygems] Don't use util_installer for user install
It is not nice to require install directory to be always specified,
while this option is later ignored for user installed gems.

Actually, the next step will be to remove `check_install_dir` check and
let the install dir override the user install.

beb79e929f
2023-11-08 09:04:28 +09:00
Vít Ondruch
d0ad90df68
[rubygems/rubygems] Check for :install_dir precedence over :user_install
6539da07aa
2023-11-08 09:04:28 +09:00
Vít Ondruch
42cf1307c3
[rubygems/rubygems] Make the user installation less exceptional
The main purpose is to put handling of user installation into the same
place as e.g. handling the --build-root option handling. There is no
reason why the --build-root option should not prefix also paths used for
user installation.

Please note that the `util_installer` in
`test_generate_plugins_with_user_install` enforced the `:install_dir`,
which is against what user install is about.

0b10cb41aa
2023-11-08 09:04:28 +09:00
Ellen Marie Dash
acd428c823
[rubygems/rubygems] Remove kludge that should be unnecessary.
f1d44ecb62
2023-11-08 09:04:28 +09:00
Ellen Marie Dash
55840d0a33
[rubygems/rubygems] Allow test_gem_install_update_options to raise Errno::ACCES, in addition to Gem::FilePermissionError.
784fe2a814
2023-11-08 09:04:28 +09:00
Peter Zhu
aa6642de63 Use embedded TypedData for Time objects
This drops the total size of a Time object from 86 bytes to 80 bytes.

Running the benchmark benchmark/time_now.yml, this commit improves
performance of Time.now by about 30%:

```
  Time.now
Branch:  13159405.4 i/s
Master:  10036908.7 i/s - 1.31x  slower

  Time.now(in: "+09:00")
Branch:   2712172.6 i/s
Master:   2138637.9 i/s - 1.27x  slower
```

It also decreases memory usage by about 20%:

```
ary = 10_000_000.times.map { Time.now }

puts `ps -o rss= -p #{$$}`
```

Branch: 961792
Master: 1196544

Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
2023-11-07 15:48:06 -05:00
Jemma Issroff
bc07b0b9e1 [PRISM] Implement compilation for different parameters
This commit compiles most parameter types, setting appropriate values on
the ISEQ_BODY. It also adds tests for callers and callees of methods,
using many versions of tests from bootstraptest
2023-11-07 15:15:16 -03:00
Nobuyoshi Nakada
1910bd4247
String for string literal is not resizable 2023-11-08 00:59:45 +09:00
Matt Valentine-House
8ef7f27321 [PRISM] CompileEnsureNode 2023-11-07 14:03:57 +00:00
Jean Boussier
ced84beb25 [ruby/cgi] Add snake case aliases for escapeURIComponent
As agreed in [Feature #18822]

9d1161ec9d
2023-11-07 10:22:30 +00:00
John Bachir
77f9086768 [ruby/timeout] tests for blank seconds
54bc7639d2
2023-11-07 15:29:58 +09:00
John Bachir
f26e89c4a7 [ruby/timeout] nested exception tests for discussion
3e42aa4d84
2023-11-07 04:45:29 +00:00
Stan Lo
2dd32e7c3b [ruby/reline] Test Reline::Face without mocking
(https://github.com/ruby/reline/pull/600)

* Test Reline::Face without mocking

Because `test-unit-rr` is not a default gem, using it would break CRuby's
CI.

* Add ruby-core workflow

d2189ac436
2023-11-06 15:53:38 +00:00
HASUMI Hitoshi
16403f41ab [ruby/reline] Introduce a new class Reline::Face to configure
character attributes
(https://github.com/ruby/reline/pull/552)

* Reine::Face

* fix test_yamatanooroti

* Define singleton methods to make accessors to attributes of a face

* s/display/foreground/

* s/default/default_style/ && s/normal_line/default/ && s/enhanced_line/enhanced/

* fix typo

* FaceConfig.new now takes keyword arguments

* Update lib/reline/face.rb

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Update test/reline/test_face.rb

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Fix to correspond to frozen_string_literal

* Face::FaceConfig -> Face::Config

* ref https://github.com/ruby/reline/pull/552#pullrequestreview-1677282576

* delete unused ivar

* ref https://github.com/ruby/reline/pull/552#discussion_r1358783723

* insert "\e[0m" into all SGR

* tiny fix

* ESSENTIAL_DEFINE_NAMES

ref https://github.com/ruby/reline/pull/552#discussion_r1367722247

* Change to Hash-accessor style

- Reline::Face[:completion_dialog].enhanced ->
  Reline::Face[:completion_dialog][:enhanced]
- Reline::Face.configs shows all defined values

* Cache array method call in local variable

* Tests for Face configuration variations

* resolve https://github.com/ruby/reline/pull/552#pullrequestreview-1710938154

* amend  to

* check invalid SGR parameter in :style

* The order of define values should be preserved

* Update test/reline/test_face.rb

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Update test/reline/test_face.rb

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Add methods: load_initial_config and reset_to_initial_config. And teardown in tests

* omission in amending "style: :default" to "style: :reset"

* refs https://github.com/ruby/reline/issues/598

* Fix link

* amend method name

* Update lib/reline/face.rb

Co-authored-by: ima1zumi <52617472+ima1zumi@users.noreply.github.com>

---------

fdc1d3b1e5

Co-authored-by: Stan Lo <stan001212@gmail.com>
Co-authored-by: ima1zumi <52617472+ima1zumi@users.noreply.github.com>
2023-11-06 14:40:42 +00:00
Jemma Issroff
f6ba87ca88 [PRISM] Implement compilation for MultiWriteNodes, fix MultiTargetNodes
Compilation now works for MultiWriteNodes and MultiTargetNodes, with
nesting on MultiWrites. See the tests added in this commit for example
behavior.
2023-11-06 10:39:07 -03:00
Jean Boussier
4a6bdbd6dc generic_ivar_set: properly check for TOO_COMPLEX on capacity transition 2023-11-06 12:39:52 +01:00
Nobuyoshi Nakada
4329554f17 [Bug #19985] Raise LoadError with the converted feature name
`Kernel#require` converts feature name objects that have the `to_path`
method such as `Pathname`, but had used the original object on error
and had resulted in an unexpected `TypeError`.
2023-11-06 17:58:47 +09:00
alpaca-tc
8ed733f8f2 ast.rb: Fix bug for source of multibyte characters
first_column and last_column return byte positions, but existing implementations
did not consider multibyte.
2023-11-05 00:54:22 +09:00
Takashi Kokubun
9f95b6eb5d Skip a test that is flaky with RJIT
It's crashing inside the bug reporter after a crash, so not sure why
it's crashing. It's not really useful for maintaining RJIT to flag this
test failure, so let's just ignore it until we figure out why it fails.

1835843916
2023-11-03 22:18:16 -07:00
Matt Valentine-House
cdb410f688 [PRISM] Fix stack consistency with Popped begin
When a begin node is popped it only needs to putnil if that nil is going
to be the return value, otherwise it can successfully be optimised out.
2023-11-03 15:19:28 +00:00