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

18608 Коммитов

Автор SHA1 Сообщение Дата
Alan Wu 2131d04f43 YJIT: Add support for `**kwrest` parameters
Now that `...` uses `**kwrest` instead of regular splat and
ruby2keywords, we need to support these type of methods to
support `...` well.
2024-02-12 13:57:24 -05:00
tomoya ishida 7af97dc71f [ruby/irb] Powerup show_source by enabling RubyVM.keep_script_lines
(https://github.com/ruby/irb/pull/862)

* Powerup show_source by enabling RubyVM.keep_script_lines

* Add file_content field to avoid reading file twice while show_source

* Change path passed to eval, don't change irb_path.

* Encapsulate source coloring logic and binary file check insode class Source

* Add edit command testcase when irb_path does not exist

* Memoize irb_path existence to reduce file existence check calculating eval_path

https://github.com/ruby/irb/commit/239683a937
2024-02-12 18:38:30 +00:00
Alan Wu e878bbd641 Allow `foo(**nil, &block_arg)`
Previously, `**nil` by itself worked, but if you add a block argument,
it raised a conversion error. The presence of the block argument
shouldn't change how keyword splat works.

See: <https://bugs.ruby-lang.org/issues/20064>
2024-02-12 13:02:50 -05:00
Kevin Newton e08c128417 [ruby/prism] Error messages closer to CRuby
https://github.com/ruby/prism/commit/19ffa0b980
2024-02-12 18:01:45 +00:00
Kevin Newton 94bc5ad30a [ruby/prism] ruby_parser translator
https://github.com/ruby/prism/commit/1925b970c7
2024-02-12 17:54:54 +00:00
Kevin Newton c3886c12dc [ruby/prism] Fix unary not location
https://github.com/ruby/prism/commit/861689f6d1
2024-02-12 16:27:49 +00:00
Noah Gibbs 16b39072a5 [ruby/prism] Move Prism::RipperCompat to Prism::Translation::Ripper
https://github.com/ruby/prism/commit/c0331abe4f
2024-02-12 15:57:57 +00:00
Kevin Newton 78deba1aa1 [ruby/prism] Unary not name location
https://github.com/ruby/prism/commit/78190d2999
2024-02-12 15:57:17 +00:00
tomoya ishida 06995eb45b [ruby/irb] Fix exit! command warning and method behavior
(https://github.com/ruby/irb/pull/868)

* Fix exit! command warning and method behavior

* Remove arg(0) from Kernel.exit and Kernel.exit!

https://github.com/ruby/irb/commit/372bc59bf5
2024-02-12 11:28:54 +00:00
Jeremy Evans c20e819e8b Fix crash when passing large keyword splat to method accepting keywords and keyword splat
The following code previously caused a crash:

```ruby
h = {}
1000000.times{|i| h[i.to_s.to_sym] = i}
def f(kw: 1, **kws) end
f(**h)
```

Inside a thread or fiber, the size of the keyword splat could be much smaller
and still cause a crash.

I found this issue while optimizing method calling by reducing implicit
allocations.  Given the following code:

```ruby
def f(kw: , **kws) end
kw = {kw: 1}
f(**kw)
```

The `f(**kw)` call previously allocated two hashes callee side instead of a
single hash.  This is because `setup_parameters_complex` would extract the
keywords from the keyword splat hash to the C stack, to attempt to mirror
the case when literal keywords are passed without a keyword splat.  Then,
`make_rest_kw_hash` would build a new hash based on the extracted keywords
that weren't used for literal keywords.

Switch the implementation so that if a keyword splat is passed, literal keywords
are deleted from the keyword splat hash (or a copy of the hash if the hash is
not mutable).

In addition to avoiding the crash, this new approach is much more
efficient in all cases.  With the included benchmark:

```
                                1
            miniruby:   5247879.9 i/s
     miniruby-before:   2474050.2 i/s - 2.12x  slower

                        1_mutable
            miniruby:   1797036.5 i/s
     miniruby-before:   1239543.3 i/s - 1.45x  slower

                               10
            miniruby:   1094750.1 i/s
     miniruby-before:    365529.6 i/s - 2.99x  slower

                       10_mutable
            miniruby:    407781.7 i/s
     miniruby-before:    225364.0 i/s - 1.81x  slower

                              100
            miniruby:    100992.3 i/s
     miniruby-before:     32703.6 i/s - 3.09x  slower

                      100_mutable
            miniruby:     40092.3 i/s
     miniruby-before:     21266.9 i/s - 1.89x  slower

                             1000
            miniruby:     21694.2 i/s
     miniruby-before:      4949.8 i/s - 4.38x  slower

                     1000_mutable
            miniruby:      5819.5 i/s
     miniruby-before:      2995.0 i/s - 1.94x  slower
```
2024-02-11 22:48:38 -08:00
eileencodes a3ceb69168 [PRISM] Fix error handling in `pm_parse_prism`
Following changes made in ruby/prism#2365 this implements error handling
for when `pm_string_mapped_init` returns `false`.

Related: ruby/prism#2207
2024-02-11 09:41:20 -05:00
Stan Lo 5c4657f883 [ruby/irb] Polish the exit! command and its tests
(https://github.com/ruby/irb/pull/867)

* Remove IRB.irb_exit! method

It's not necessary to introduce a new method just for the exit! command
at this moment.

* Rename ExitForcedAction to ForceExit

* Move force exit tests to a dedicated file

* Fix nested history saving with exit! command

Because we switched to use `Kernel#exit` instead of `exit!`, the outer
session's ensure block in `Irb#run` will be run, which will save the
history. This means the separate check to save history when force exiting
is no longer necessary.

* execute_lines helper should also capture IRB setup's output

This prevents setup warnings from being printed to test output
while allowing those output to be tested.

* Update readme

https://github.com/ruby/irb/commit/899d10ade1
2024-02-11 05:17:40 +00:00
Ignacio Chiazzo Cardarello 429eeb09f2 [ruby/irb] Introduce exit! command
(https://github.com/ruby/irb/pull/851)

* Added failing test for when writing history on exit

* Save history on exit

* Exit early when calling Kernel.exit

* use status 0 for kernel.exit

* Added test for nested sessions

* Update lib/irb.rb

---------

https://github.com/ruby/irb/commit/c0a5f31679

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-02-10 22:07:53 +00:00
yui-knk ea91ab696e Fix constant name of `Ractor::IsolationError` message
`dest` of `const_decl_path` is `NODE_COLON2` or `NODE_COLON3` in some cases.
For example, `B::C ||= [“Not ” + “shareable”]` passes `NODE_COLON2`
and `::C ||= [“Not ” + “shareable”]` passes `NODE_COLON3`.
This commit fixes `Ractor::IsolationError` message for such case.

```
# shareable_constant_value: literal
::C ||= ["Not " + "shareable"]

# Before
# => cannot assign unshareable object to C (Ractor::IsolationError)

# After
# => cannot assign unshareable object to ::C (Ractor::IsolationError)
```
2024-02-10 09:23:17 +09:00
yui-knk bf72cb84ca Include the first constant name into `Ractor::IsolationError` message
If lhs of assignment is top-level constant reference, the first
constant name is omitted from error message.
This commit fixes it.

```
# shareable_constant_value: literal
::C = ["Not " + "shareable"]

# Before
# => cannot assign unshareable object to  (Ractor::IsolationError)

# After
# => cannot assign unshareable object to ::C (Ractor::IsolationError)
```
2024-02-10 09:23:17 +09:00
Kevin Newton e96c838ca4 [PRISM] Fix flaky memory in scope nodes 2024-02-09 16:30:07 -05:00
Noah Gibbs f635b4dd0e [ruby/prism] RipperCompat: add array-refs, assigns, symbols, strings
https://github.com/ruby/prism/commit/b771c7f2ec
2024-02-09 19:49:27 +00:00
Jean Boussier d19d683a35 rb_obj_setup: do not copy RUBY_FL_SEEN_OBJ_ID
[Bug #20250]

We're seting up a new instance, so it never had an associated
object_id.
2024-02-09 17:38:54 +01:00
Nobuyoshi Nakada db73226bf6 [ruby/optparse] Adjust arguments for lambda-callbacks
Rake uses [lambda] as callbacks.
Calling it without omitted argument raises an `ArgumentError`.

lambda: https://github.com/ruby/rake/blob/master/lib/rake/application.rb#L543

https://github.com/ruby/optparse/commit/213cb03b59
2024-02-09 19:58:31 +09:00
Nobuyoshi Nakada 2c6767b71e [ruby/optparse] Respect default values in block parameters
Fix https://github.com/ruby/optparse/pull/55

https://github.com/ruby/optparse/commit/9d53e74aa4
2024-02-09 19:58:19 +09:00
fatkodima f7a407cabd [ruby/optparse] Fix `require_exact` to work with options defined as `--[no]-something`
https://github.com/ruby/optparse/commit/4e346ad337
2024-02-09 03:31:13 +00:00
Petrik 2a57e6e6ed [ruby/rdoc] Don't document aliases with trailing `:nodoc` directive
Attribute readers and writers can be marked as `:nodoc` to keep them
undocumented:

```ruby
attr_reader :name # :nodoc:
```

For aliases this behaviour should be the same:

```ruby
alias_method :old :new # :nodoc:
```

https://github.com/ruby/rdoc/commit/30f14e8271
2024-02-09 01:07:17 +00:00
Noah Gibbs 366af4679e [ruby/prism] RipperCompat: support for more features.
* add bin/prism ripper to compare Ripper output
* block arg handling is quirky, do it per-call-site
* block required params
* boolean values
* various assign-operator support
* breaks, early fragile begin/rescue/end
* more fixtures being checked

https://github.com/ruby/prism/commit/31732cb720
2024-02-08 16:02:04 +00:00
Peter Zhu 01fd262e62 Fix crash when checking symbol encoding
[Bug #20245]

We sometimes pass in a fake string to sym_check_asciionly. This can crash
if sym_check_asciionly raises because it creates a CFP with the fake
string as the receiver which will crash if GC tries to mark the CFP.

For example, the following script crashes:

    GC.stress = true
    Object.const_defined?("\xC3")
2024-02-08 10:12:56 -05:00
Charles Oliver Nutter 39f2e37ff1
[ruby/strscan] Don't add begin to length for new string slice
(https://github.com/ruby/strscan/pull/87)

Fixes https://github.com/ruby/strscan/pull/86

https://github.com/ruby/strscan/commit/c17b015c00
2024-02-08 14:43:56 +09:00
Noah Gibbs 5b7baa0486 [ruby/prism] More different block-call syntaxes, support more types of method calls
https://github.com/ruby/prism/commit/40cf114a24
2024-02-07 19:42:13 +00:00
Noah Gibbs 73d222e1ef [ruby/prism] Support &. calls and calling with blocks, test with fixtures
https://github.com/ruby/prism/commit/e346fa583a
2024-02-07 19:42:13 +00:00
Noah Gibbs b1310940e3 [ruby/prism] RipperCompat: support more kinds of method calls and operators.
Add tests. Start parsing some simpler fixture code.

https://github.com/ruby/prism/commit/997f4191d8
2024-02-07 19:42:13 +00:00
Kevin Newton aad3c36bdf [ruby/prism] Support for Ruby 2.7
https://github.com/ruby/prism/commit/1a15b70a8e
2024-02-07 16:54:34 +00:00
Stan Lo 5f4245e74b [ruby/irb] Polish tracer integration and tests
(https://github.com/ruby/irb/pull/864)

* Remove useless ivar

* Simplify tracer test setup

* Treat tracer like a normal development dependency

* Only require ext/tracer when value is truthy

* Make tracer integration skip IRB traces

https://github.com/ruby/irb/commit/a97a4129a7
2024-02-07 14:59:10 +00:00
Hiroshi SHIBATA d95d3484a9
omit tests related legacy provider
It failed with recent update of FreeBSD

https://rubyci.s3.amazonaws.com/freebsd13/ruby-master/log/20240207T023002Z.fail.html.gz
2024-02-07 16:06:01 +09:00
Kim Emmanuel 8bd83bb133 [rubygems/rubygems] fix flaky tests
https://github.com/rubygems/rubygems/commit/0e87ae032d
2024-02-07 05:46:50 +00:00
Kim Emmanuel aaef443a59 [rubygems/rubygems] release requirement may load prerelease when sole option
https://github.com/rubygems/rubygems/commit/7990771939
2024-02-07 05:46:49 +00:00
Kim Emmanuel 5ddf4f5c95 [rubygems/rubygems] fix Gem::Dependency#to_spec returning nil when prerelease is the only available version
https://github.com/rubygems/rubygems/commit/a7dcc7214b
2024-02-07 05:46:49 +00:00
Kevin Newton 2dba441397 [ruby/prism] Even more ripper compat
https://github.com/ruby/prism/commit/47a602dc1c
2024-02-07 03:21:02 +00:00
NARUSE, Yui 64b6a018a3
Fix test session reuse but expire (#9824)
* OpenSSL 3.2.1 30 Jan 2024 is also broken

Import 4506461072 from ruby_3_3 branch
tentatively.
2024-02-07 10:59:59 +09:00
Noah Gibbs e34505c631 [ruby/prism] More visitors and tests for RipperCompat
Part of issue #2354

https://github.com/ruby/prism/commit/cb28edae34
2024-02-07 01:49:54 +00:00
Kevin Newton ae13f85322 Add test-all to prism 2024-02-06 20:38:41 -05:00
eileencodes 936c0ab5e8 [ruby/prism] Implement file parsing error handling
This PR implements proper file parsing error handling. Previously
`file_options` would call `pm_string_mapped_init` which would print an
error from `perror`. However this wouldn't raise a proper Ruby error so
it was just a string output. I've done the following:

- Raise an error from `rb_syserr_fail` with the filepath in
`file_options`.
- No longer return `Qnil` if `file_options` returns false (because now
it will raise)
- Update `file_options` to return `static void` instead of `static
bool`.
- Update `file_options` and `profile_file` to check the type so when
passing `nil` we see a `TypeError`.
- Delete `perror` from `pm_string_mapped_init`
- Update `FFI` backend to raise appropriate errors when calling
`pm_string_mapped_init`.
- Add tests for `dump_file`, `lex_file`, `parse_file`,
`parse_file_comments`, `parse_lex_file`, and `parse_file_success?`
when a file doesn't exist and for `nil`.
- Updates the `bin/parse` script to no longer raise it's own
`ArgumentError` now that we raise a proper error.

Fixes: ruby/prism#2207

https://github.com/ruby/prism/commit/b2f7494ff5
2024-02-06 20:49:33 +00:00
Nikita Vasilevsky c3403322df [PRISM] Use block node location when building block iseq
Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-02-06 14:56:10 -05:00
Kevin Newton f5b368df0c [ruby/prism] Better invalid token messages
https://github.com/ruby/prism/commit/8c9bed2a4d
2024-02-06 18:10:50 +00:00
Nuno Silva 300dee1fe8 [ruby/irb] Fix usage of tracer gem and add tests
(https://github.com/ruby/irb/pull/857)

The new tests are skipped when ruby below 3.1, as it was a default gem on it, and in a version we do not support.

This also move definition of `use_tracer` to module Context instead of monkey patch.

https://github.com/ruby/irb/commit/08834fbd5f
2024-02-06 16:46:50 +00:00
Yusuke Endoh 19f615521d Remove TestProcess#test_low_memory_startup
It is too flaky on many platforms. Nobody is willing to fix it. Let's
just stop it.
2024-02-04 05:02:49 +09:00
Kevin Newton c42b1029d9 [ruby/prism] Change the location of an implicit begin to method
https://github.com/ruby/prism/commit/d08e140859
2024-02-05 20:40:24 +00:00
David Rodriguez ca7a48110f [rubygems/rubygems] Revert "Simplify how extensions are built"
This reverts commit https://github.com/rubygems/rubygems/commit/0b8faf1e3926.

https://github.com/rubygems/rubygems/commit/7528e0f1ce
2024-02-05 18:17:24 +00:00
Peter Zhu 948c618bda [PRISM] Fix encoding of interpolated strings
Fixes ruby/prism#2313.
2024-02-05 11:55:44 -05:00
Kevin Newton 0b5be2f9e9 Sync to latest prism 2024-02-05 11:07:07 -05:00
Jenny Shen b35cdb4758 [PRISM] Implement opt_aset_with
Part of ruby/prism#2231

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2024-02-05 10:27:58 -05:00
NARUSE, Yui bc79229be9 Show OpenSSL version in the error message of assert_equal 2024-02-03 19:39:17 +09:00
Nobuyoshi Nakada 124be0aaaa [ruby/irb] Consume the warning for non-existent history path
Fix https://github.com/ruby/irb/pull/852#issuecomment-1925170358

https://github.com/ruby/irb/commit/9a7e060e57
2024-02-03 06:54:35 +00:00