Commit graph

21005 commits

Author SHA1 Message Date
Erik Berlin
4431ca5363 [ruby/fileutils] FileUtils.remove_dir checks directory
f0d7fc817b
2025-07-19 13:54:45 +00:00
Nobuyoshi Nakada
3dced7955c [ruby/fileutils] Use shorter symlink by real paths
277f7f2ff8
2025-07-19 13:47:48 +00:00
Nobuyoshi Nakada
de68f22042 [ruby/fileutils] Fix up FileUtils#ln_sr
2836a164ed
2025-07-19 13:47:47 +00:00
Stan Lo
8df61bfc92
ZJIT: Support invalidating on method redefinition (#13875)
ZJIT: Support invalidating method redefinition

This commit adds support for the MethodRedefined invariant to be invalidated
when a method is redefined.

Changes:
- Added CME pointer to the MethodRedefined invariant in HIR
- Updated all places where MethodRedefined invariants are created to
    include the CME pointer
- Added handling for MethodRedefined invariants in gen_patch_point to
    call track_cme_assumption, which registers the patch point for
    invalidation when rb_zjit_cme_invalidate is called

This ensures that when a method is redefined, all JIT code that
depends on that method will be properly invalidated.
2025-07-18 15:36:51 +00:00
Nobuyoshi Nakada
cfe8263f41 [ruby/fileutils] Fix ln_sf with multiple sources and target_directory: false
In this case, an ArgumentError is now raised rather than ignoring the
option, just as GNU coreutils' `ln` would error on the command line.
Fixes https://github.com/ruby/fileutils/pull/128 as well.

4fc578a75f
2025-07-18 09:22:34 +00:00
Yusuke Endoh
dc8ae24951 Revert "[Bug #21256] Fix it parameter when splatting and define_method is…"
This reverts commit 265059603c.
2025-07-18 13:28:46 +09:00
Stan Lo
81515aca67
ZJIT: Fix fixnum folding for negative values (#13942)
Use `fixnum_from_isize` instead of `fixnum_from_usize` in
`fold_fixnum_bop` to properly handle negative values. Casting negative
`i64` to `usize` produces large unsigned values that exceed `RUBY_FIXNUM_MAX`.
2025-07-17 19:48:53 -04:00
Aaron Patterson
86320a5300 Fix compilation for forwarding params in Prism
[Bug #21326]
2025-07-17 18:00:33 -04:00
Earlopain
265059603c [Bug #21256] Fix it parameter when splatting and define_method is used
It was failing to set the leads, like numblocks do, causing the result to be wrapped in an array
2025-07-17 16:18:17 -04:00
Takashi Kokubun
04d43e1870
ZJIT: Give up JIT-to-JIT calls for 6+ args (#13939) 2025-07-17 12:22:26 -07:00
Aaron Patterson
c1c9deea83 [ruby/prism] Revert "Merge pull request #3598 from Shopify/fix-3473"
This reverts commit bc446fb979, reversing
changes made to 71432af1eb.

e5ca485f4e
2025-07-17 16:23:17 +00:00
Stan Lo
13de248f39 [ruby/prism] Allow command calls in endless method bodies regardless of context
Previously, endless method definitions like `x = def f = p 1` would fail
to parse because command calls (method calls without parentheses) were
only accepted when the surrounding binding power was less than
`PM_BINDING_POWER_COMPOSITION` (8). In assignment contexts with binding
power 18, this condition was false, causing parse errors.

This fix ensures command calls are always accepted in endless method
bodies by passing `true` for `accepts_command_call`, making the method
body parse consistently regardless of where the method is defined.

70413ed4dd
2025-07-17 16:06:34 +00:00
Misaki Shioi
ba490059b4
[Feature #21347] Add open_timeout as an overall timeout option for TCPSocket.new (#13909)
* [Feature #21347] Add `open_timeout` as an overall timeout option for `TCPSocket.new`

With this change, `TCPSocket.new` now accepts the `open_timeout` option.
This option raises an exception if the specified number of seconds has elapsed since the start of the method call,
even if the operation is still in the middle of name resolution or connection attempts.

The addition of this option follows the same intent as the previously merged change to `Socket.tcp`.
[Feature #21347](https://bugs.ruby-lang.org/issues/21347)
https://github.com/ruby/ruby/pull/13368

* Tidy up: Extract rsock_raise_user_specified_timeout()

* Added a note to the documentation of `Socket.tcp`

* Fix `rsock_init_inetsock` for `FAST_FALLBACK_INIT_INETSOCK_IMPL`
2025-07-17 18:15:19 +09:00
David Rodríguez
851a3e7724 [rubygems/rubygems] Restore treating "--" as an unknown platform
Rather than crashing when parsing it.

aa0064e4c7
2025-07-17 11:07:22 +09:00
Stan Lo
d207efecec ZJIT: Remove unneeded test exclusions
After several ZJIT fix PRs, the number of failing/crashing tests for
ZJIT has dropped significantly. This removes the unneeded test exclusions.
2025-07-16 14:31:19 -07:00
Max Bernstein
900eb04853
ZJIT: Split shift with immediate operand (#13914)
Fix https://github.com/Shopify/ruby/issues/627
2025-07-16 19:50:33 +00:00
Earlopain
133cf95618 [ruby/prism] [Bug #21345] Fix accepting multiple rest patterns with leading match
Related:
* https://bugs.ruby-lang.org/issues/20765
* https://github.com/ruby/prism/issues/2915

de56fa4a34
2025-07-16 18:12:06 +00:00
Takashi Kokubun
2796479589 test_process.rb: UID.from_name may raise Errno::ENOENT
See: 58bc97628c

getpwnam(3) says the same thing. I got ENOENT in my Linux environment.

  1) Failure:
TestProcess#test_uid_from_name [/home/k0kubun/src/github.com/ruby/ruby/test/ruby/test_process.rb:1685]:
Exception(ArgumentError) with message matches to /\u{4e0d 5b58 5728}/.
[ArgumentError] exception expected, not #<Errno::ENOENT: No such file or directory - getpwnam_r>.
2025-07-16 10:42:22 -07:00
Stan Lo
2591b93593 [ruby/prism] Fix crash when using arithmetic expressions in pattern matching
When arithmetic expressions like `-1**2` are used in pattern matching contexts,
Ruby crashes with "Unexpected node type in pattern matching expression: PM_CALL_NODE".
This happens because the Prism parser creates `PM_CALL_NODE` for arithmetic operations,
but Ruby's pattern matching compiler doesn't handle call nodes.

This fix adds validation to reject `PM_CALL_NODE` in pattern contexts with a proper
syntax error.

365049a767
2025-07-16 17:08:28 +00:00
Takashi Kokubun
2250a66aa8 ZJIT: Fix SP alignment on JIT entry for x86_64 2025-07-16 09:50:25 -07:00
ydah
4eb0a6cd4d [ruby/prism] Improve error handling for missing parentheses after 'not' in command calls
d9151b8a82
2025-07-16 15:48:09 +00:00
Yusuke Endoh
4cf85fe214 [ruby/prism] Reject true && not true
A command-call-like `not true` must be rejected after `&&` and `||`.

https://bugs.ruby-lang.org/issues/21337

0513cf22ad
2025-07-16 15:48:09 +00:00
Nobuyoshi Nakada
3956308aa4
test_defined_paren_void_stmts passes with parse.y now 2025-07-16 16:38:55 +09:00
Stan Lo
5723945335
ZJIT: Start testing against /test/ruby/ and update all ZJIT related testing targets/docs (#13791)
* ZJIT: Add test exclusions for ZJIT

* ZJIT: Update test targets and documentation

- Rename `zjit-test-all` to `zjit-check`
- Add `zjit-test-all` target to zjit.mk to run all Ruby tests with ZJIT enabled
  excluding known failing tests
- Update documentation and CI workflow to reflect the new targets
2025-07-15 15:03:40 -07:00
Alan Wu
0aefa4956d ZJIT: Add failing test to test_spilled_method_args() 2025-07-15 14:47:32 -04:00
Nobuyoshi Nakada
35660ec17d
Suppress warnings for variables 2025-07-16 00:03:04 +09:00
Nobuyoshi Nakada
562599e6bc
Skip URI::TestMailTo#test_email_regexp for now 2025-07-15 16:52:03 +09:00
Takashi Kokubun
e288a86692
ZJIT: Restore SP register after JIT-to-JIT call (#13882)
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
Co-authored-by: Stan Lo <stan.lo@shopify.com>
2025-07-14 12:22:13 -07:00
David Rodríguez
7a03a02bee
[rubygems/rubygems] Fix more warnings when running old Bundler with latest RubyGems
Also fix platform warnings when Bundler's entrypoint is bundler's
binstub.

4b1df58403
2025-07-14 11:52:14 +09:00
David Rodríguez
15751af90b
[rubygems/rubygems] Improve some heredoc indentations
6ee3a33048
2025-07-14 11:52:13 +09:00
David Rodríguez
f1cbd58acc
[rubygems/rubygems] Stop generating binstubs with support for RubyGems before 2.6.2
RubyGems generated binstubs still provide support for this ancient
version. This makes no sense since we prevent downgrades to such old
versions.

089cdc3b77
2025-07-14 11:52:13 +09:00
Nobuyoshi Nakada
f03cc0b514 [ruby/uri] Repeat matching to reduce deviations
fa49e5b8ae
2025-07-13 04:37:15 +00:00
Nobuyoshi Nakada
9c166d26b2 [ruby/uri] Test in exponential scale with rehearsal
be35e0b4d8
2025-07-13 04:37:15 +00:00
Kazuki Yamaguchi
753e3b7ae3 [ruby/openssl] asn1: align UTCTime year range with RFC 5280
ASN.1 UTCTime uses two-digit years. While X.680 does not specify how to
map them as far as I can tell, X.509/PKIX uses this type to represent
dates between year 1950-2049.

OpenSSL::ASN1.decode has used 1969-2068 since the initial
implementation. Given that ASN1::UTCTime#to_der relies on OpenSSL
ASN1_UTCTIME type, which assumes the 1950-2049 range, this was likely
unintentional.

Use the range 1950-2049 consistently, and fix decoding of X.509
certificates with dates in 1950-1968.

b8b38e1438
2025-07-12 13:25:24 +00:00
Nobuyoshi Nakada
cf7b871a94 [ruby/uri] Improve performance of URI::MailTo::EMAIL_REGEXP
Fix the performance regression at #172 for valid emails.

``` yml
prelude: |
  require 'uri/mailto'
  n = 1000
  re = URI::MailTo::EMAIL_REGEXP
benchmark:
  n.t..t.: re.match?("n.t..t.@docomo.ne.jp")
  example: re.match?("example@example.info")
```

|         |released| 788274b| c5974f0|    this|
|:--------|-------:|-------:|-------:|-------:|
|n.t..t.  |  3.795M|  4.864M|  4.993M|  8.739M|
|         |       -|   1.28x|   1.32x|   2.30x|
|example  |  3.911M|  3.740M|  2.838M|  3.880M|
|         |   1.38x|   1.32x|       -|   1.37x|

7363a134ac
2025-07-12 10:32:48 +00:00
Jeremy Evans
22b81b5bf5 [ruby/uri] Do not allow empty host names, as they are not allowed by RFC 3986
Pointed out by John Hawthorn.

Fixes [Bug #20686]

c0cfa04a66
2025-07-12 07:07:39 +00:00
Nobuyoshi Nakada
1add45e2a6 [ruby/uri] Prohibit successive dots in email
32335923bf
2025-07-12 07:07:05 +00:00
Nobuyoshi Nakada
859d74279a [ruby/uri] More tests for check_to
b1b5f9a476
2025-07-12 07:07:05 +00:00
Nikita Levchuk
c97eba9bcd [ruby/uri] lib/uri/mailto.rb (EMAIL_REGEXP): use assertions surrounding the local part instead of a character class
2d7d2d9988
2025-07-12 03:31:54 +00:00
Nikita Levchuk
0685e8caf9 [ruby/uri] lib/uri/mailto.rb (EMAIL_REGEXP): the local part should not contain leading or trailing dots
618e2bb640
2025-07-12 03:31:53 +00:00
Nobuyoshi Nakada
f1764623db [ruby/uri] Make URI::regexp schemes case sensitive
(https://github.com/ruby/uri/pull/38)

0c2b6468fa
2025-07-12 03:24:15 +00:00
Nobuyoshi Nakada
c47a92b63d [ruby/uri] Fix the message for unexpected argument
Use just `self` instead of `self.class`, in `URI::Generic.build`.
Since this is a class method, `self.class` is always `Class` even in
inherited sub classes, and does not have `#component` method.

6f44d3d40e
2025-07-12 03:05:25 +00:00
Takashi Kokubun
3ec46aad37
ZJIT: Mark objects baked in JIT code (#13862) 2025-07-11 13:24:08 -07:00
Takashi Kokubun
b1828cbbfe
ZJIT: Implement patch points on BOP redefinition (#13850)
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
2025-07-10 13:40:40 -07:00
Takashi Kokubun
9ab80a7455
ZJIT: Avoid optimizing locals on eval (#13840)
* ZJIT: Avoid optimizing locals on eval

* Maintain the local state for eval
2025-07-10 12:08:09 -07:00
Janosch Müller
bd18238a0e [Bug #19417] Make word prop match join_control ...
... to conform to UTS 18 as mentioned in https://bugs.ruby-lang.org/issues/19417#note-3

https://unicode.org/reports/tr18/#word states word should match join_control chars.

It currently does not:

```ruby
[*0x0..0xD799, *0xE000..0x10FFFF].map { |n| n.chr 'utf-8' } => all_chars
all_chars.grep(/\p{join_control}/) => jc
jc.count # => 2
jc.grep(/\p{word}/).count # => 0
```
2025-07-10 21:28:41 +09:00
Takashi Kokubun
f5085c70f2
ZJIT: Mark profiled objects when marking ISEQ (#13784) 2025-07-09 16:03:23 -07:00
Stan Lo
1df94aaf08 ZJIT: Name side-exit test cases correctly 2025-07-09 17:50:41 -04:00
Stan Lo
e2a81c738c ZJIT: Optimize opt_and and opt_or instructions for Fixnum 2025-07-09 17:50:41 -04:00
Nobuyoshi Nakada
25afe7ef64
Rename variables to suit each method 2025-07-09 17:56:38 +09:00