Commit graph

20692 commits

Author SHA1 Message Date
David Rodríguez
5668933296 [rubygems/rubygems] Extract a spec variable
It's consistent with the previous test and makes print debugging easier.

d7f424df16
2024-05-31 11:58:00 +00:00
David Rodríguez
21f10cabb9 [rubygems/rubygems] Improve spec about rubygems-update in non default path
Make it not also install the gem in the default GEM_HOME.

22de9a810a
2024-05-31 11:58:00 +00:00
David Rodríguez
530c85be49 [rubygems/rubygems] Remove unnecessary reset
33328e54fd
2024-05-31 11:58:00 +00:00
Sorah Fukumori
fd549b229b
test_bignum: defined? returns String (#10880)
didn't verify the test is working properly due to mistaken auto-merge… [Bug #20515] 

bug: https://bugs.ruby-lang.org/issues/20515
follow-up: 22e4eeda65
follow-up: https://github.com/ruby/ruby/pull/10875
2024-05-30 19:59:30 +00:00
Kevin Newton
4558abec02 [ruby/prism] Disallow unescape test on FFI backend
32277722d4
2024-05-30 19:36:40 +00:00
Kevin Newton
72452f4387 [ruby/prism] Tests overhaul
6f886be0a4
2024-05-30 15:18:20 -04:00
Sorah Fukumori
22e4eeda65
ci: Test whether GMP is working in compilers.yml (#10875)
Avoid reoccurence of [Bug #20515]

Requires https://github.com/ruby/ruby/pull/10876 since 18eaf0be90

bug: https://bugs.ruby-lang.org/issues/20515
2024-05-30 18:44:31 +00:00
Jean Boussier
15501e13d7 [ruby/stringio] Remove special handling of chilled strings
[Feature #20205]

Followup: https://github.com/ruby/stringio/pull/94

They no longer need to be special cases. If StringIO end up
mutating a chilled string, a warning will be emitted.

dc62d65449
2024-05-30 15:11:48 +00:00
Hiroshi SHIBATA
ba8e6e77fd
Revert "[rubygems/rubygems] Fix gem pristine sometimes failing to pristine user installed gems"
This reverts commit a3edc4abc5.

That commit caused test failure with Windows platform.

* 2556187139
* 2556187306
2024-05-30 12:46:19 +09:00
David Rodriguez
a3edc4abc5 [rubygems/rubygems] Fix gem pristine sometimes failing to pristine user installed gems
0eb6ed8f86
2024-05-29 15:35:04 +00:00
Kevin Newton
bc3199bb29 [PRISM] Enable TestAssignmentGen#test_assignment 2024-05-28 15:30:32 -04:00
Kevin Newton
a7eb3d077b [PRISM] Enable TestISeq#test_trace_points 2024-05-28 14:24:18 -04:00
Kevin Newton
07f494ccad [PRISM] Enable TestISeq#test_each_child 2024-05-28 14:24:18 -04:00
Kevin Newton
fd95ba255a Make ensure first lineno the first line of the ensure
Previously, ensure ISEQs took their first line number from the
line number coming from the AST. However, if this is coming from
an empty `begin`..`end` inside of a method, this can be all of the
way back to the method declaration. Instead, this commit changes
it to be the first line number of the ensure block itself.

The first_lineno field is only accessible through manual ISEQ
compilation or through tracepoint. Either way, this will be more
accurate for targeting going forward.
2024-05-28 13:12:21 -04:00
Kevin Newton
8f84fbbf96 [PRISM] Enable TestSyntax#test_dedented_heredoc_continued_line 2024-05-28 13:11:52 -04:00
Nobuyoshi Nakada
31c9a3a1d3 [Bug #20438] Disallow "%\n" and "%\0" 2024-05-29 01:02:32 +09:00
Étienne Barrié
1376881e9a Stop marking chilled strings as frozen
They were initially made frozen to avoid false positives for cases such
as:

    str = str.dup if str.frozen?

But this may cause bugs and is generally confusing for users.

[Feature #20205]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-05-28 07:32:33 +02:00
Yusuke Endoh
2114d0af1e Make test_nested_timeouts less flaky
This test randomly fails due to the bug reported in [Bug #20314], where
the two timeouts are too close so that they can expire at the same time.

As a workaround, this change increases the time difference between
timeouts. This will reduce the probability of simultaneous expirations
and lower flakiness.
2024-05-28 12:49:46 +09:00
verdy89
7c6e4bc7ca [ruby/reline] Implement the redo command
(https://github.com/ruby/reline/pull/707)

* Implement the redo command

* Commented out a test that does not pass

* Changed key assignment for redo from "\C-[" to "\C-g"

* Changed redo key assignment from `\C-g` to `\M-\C-_`

* Revert the first implemantation

* Implemented redo by sharing `@past_lines` between undo and redo

* Fixed the index of past_lines that is updated when the cursor is moved

* Fixed deletion of the redo history in regular input

* Renamed variables: past_lines -> input_lines

* Rename @position to @input_lines_position

* Deleted unused variables: `@old_byte_pointer` and `@old_line_index`

0b2d9fab5f
2024-05-27 16:38:22 +00:00
Yusuke Endoh
bc47ca5546 Add a debug print for a random failure
```
  1) Error:
TestRubyLiteral#test_float:
ArgumentError: SyntaxError#path changed: "(eval at /home/chkbuild/chkbuild/tmp/build/20240527T050036Z/ruby/test/ruby/test_literal.rb:642)"->"(eval at /home/chkbuild/chkbuild/tmp/build/20240527T050036Z/ruby/test/ruby/test_literal.rb:642)"
```
20240527T050036Z.fail.html.gz
2024-05-27 18:16:28 +09:00
Nobuyoshi Nakada
bc50f2a3f1
Debug unexpectedly changed path 2024-05-26 20:14:18 +09:00
Go
508f331048 [ruby/reline] allow space in config value
(https://github.com/ruby/reline/pull/705)

* allow space in config value

fix https://github.com/ruby/reline/pull/657

* remove inline comments

* Revert "remove inline comments"

This reverts commit 2438347c1a.

* refactoring

* remove unnecessary comment handling

d60f1e1e39
2024-05-26 08:28:25 +00:00
Nobuyoshi Nakada
0bae2f0002
[Bug #20510] Do not count optional hash argument for IO.new
Since `IO.new` accepts one or two positional arguments except for the
optional hash argument, exclude the optional hash argument from the
check for delegation to `IO.new`.
2024-05-25 19:15:25 +09:00
Kevin Newton
c7281e2d67 [ruby/prism] Fix up ruby_parser string concat
4b06eae0df
2024-05-24 19:27:44 +00:00
Kevin Newton
f8b750370e [ruby/prism] Remove Debug module
4d8929ff6a
2024-05-24 17:19:38 +00:00
Kevin Newton
79001c8b4a [ruby/prism] Remove error formatting, put directly in CRuby
53b2866487
2024-05-24 17:19:36 +00:00
Kevin Newton
653652bcbe [ruby/prism] Remove Debug#named_captures
5050dfbe70
2024-05-24 17:19:35 +00:00
Kevin Newton
b04c959621 [ruby/prism] Remove various unused memsize infra
283938ed1f
2024-05-24 17:19:34 +00:00
Kevin Newton
b8681c2e37 [ruby/prism] Remove Debug::integer_parse
14e397598b
2024-05-24 17:19:33 +00:00
Kevin Newton
870350253e [ruby/prism] Remove Debug::static_inspect
486c71c426
2024-05-24 17:19:33 +00:00
Kevin Newton
47f0965269 Update duplicated when clause warning message 2024-05-24 12:36:54 -04:00
Kevin Newton
7021e15652 [ruby/prism] Update duplicated when error message
54316fd8a0
2024-05-24 12:36:54 -04:00
Kevin Newton
2d4d99f78a [PRISM] Update remaining test excludes 2024-05-23 21:27:36 -04:00
eileencodes
c96b5791ef [ruby/prism] Raise void value expression in begin clauses
In some cases Prism was either not raising an appropriate `void value
expression` error, or raising that error when the syntax is considered
valid.

To fix this Prism needs to check whether we have other clauses on the
`begin` rather than just returning `cast->statements`.

* If the `cast->statements` are null and the `cast->ensure_clause` is
not null, set the code to `cast->ensure_clause`
* else
  * If there is a `cast->rescue_clause`
    * Check if `cast->statements` are null and `cast->rescue_clause->statements`
    are null, and return `NULL`
    * Check if there is an `else_clause`, and set the node to
      `cast->else_clause`.
    * Otherwise return `cast->statements` as the node
  * return `cast->statements` as the node

See tests for test cases. Note I took these directly from CRuby so if
desired I can delete them since the test will now pass. This only fixes
one test in the `test_parse` file, taking failures from 14 to 13.

This fixes `TestParse#test_void_value_in_rhs` and is related to
issue #2791.

398152b412
2024-05-23 19:30:03 +00:00
Nobuyoshi Nakada
49fcd33e13 Introduce a specialize instruction for Array#pack
Instructions for this code:

```ruby
  # frozen_string_literal: true

[a].pack("C")
```

Before this commit:

```
== disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)>
0000 putself                                                          (   3)[Li]
0001 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0003 newarray                               1
0005 putobject                              "C"
0007 opt_send_without_block                 <calldata!mid:pack, argc:1, ARGS_SIMPLE>
0009 leave
```

After this commit:

```
== disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)>
0000 putself                                                          (   3)[Li]
0001 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0003 putobject                              "C"
0005 opt_newarray_send                      2, :pack
0008 leave
```

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2024-05-23 12:11:50 -07:00
Kevin Newton
56a51fcd33 [PRISM] Fix up some masgn topn calculations 2024-05-23 13:22:22 -04:00
Kevin Newton
0ebd37234e [PRISM] Enable TestSyntax#test_unterminated_heredoc_cr 2024-05-23 12:41:22 -04:00
Kevin Newton
6d81ae3f01 [PRISM] Properly support 'it' 2024-05-22 16:34:04 -04:00
Kevin Newton
e575954887 [ruby/prism] Fix support for 'it' implicit local variable
53bbcfe513
2024-05-22 16:34:04 -04:00
Kevin Newton
b20adf90e3 [ruby/prism] Fix up ruby_parser interpolation concatenation
79cec4be22
2024-05-21 18:45:16 +00:00
Kevin Newton
89efb94fec [ruby/prism] Reconfigure rationals
This eliminates the subnode on RationalNode and replaces it with two
integer fields, which represent the ratio for the rational. It also
reduces those two integers if they both fit into 32 bits.

Importantly, this PR does not implement bignum reduction. That's something
I'd like to consider for the future, but it's simple enough for now to
leave them unreduced, which makes it more useful than it used to be.

86e06c7068
2024-05-21 14:27:46 -04:00
Kevin Newton
16b0bb3d53 [PRISM] Enable TestSyntax#test_warn_balanced 2024-05-21 14:27:28 -04:00
Kevin Newton
bcbfc675a4 [PRISM] Enable TestSyntax#test_numbered_parameter 2024-05-21 12:56:20 -04:00
Kevin Newton
ff43b4a28b [ruby/prism] Add error for numbered parameter used in inner block
c386ba6d48
2024-05-21 15:46:45 +00:00
Kevin Newton
6ddc0a8044 [PRISM] Enable TestRegexp#test_unescape 2024-05-20 21:25:51 -04:00
Kevin Newton
e82c7a0577 [PRISM] Enable TestRegexp#test_match_control_meta_escape 2024-05-20 21:25:51 -04:00
Jeremy Evans
86cf074fa1 Avoid array allocation for empty ruby2_keywords flagged keyword hash
If the method being called does not have a positional splat
parameter, there is no point in allocating the array, as
decrementing given_argc is sufficient to ensure the empty keyword
hash is not considered an argument, assuming that we are calling
a method/lambda and not a regular proc.
2024-05-21 05:33:57 +09:00
Jeremy Evans
2433b57b6a Avoid hash allocation for empty ruby2_keywords flagged keyword hash
If the method being called does not have a keyword splat parameter,
there is no point in allocating the hash, because the hash will
be unused (as empty keyword hashes are ignored).
2024-05-21 05:33:57 +09:00
Jeremy Evans
f021bcdbbe Add allocation tests for ruby2_keywords
This tests ruby2_keywords flagged methods, as well as passing
ruby2_keywords flagged hashes to other methods.

Some of the behavior here is questionable, such as allocating
different numbers of objects depending on whether a block is
passed or whether YJIT is enabled. I think there are likely ways
to eliminate allocations in certain cases.  However, this gives
us a baseline and shows us where it is possible to make
improvements.
2024-05-21 05:33:57 +09:00
Kevin Newton
78e504f21d [PRISM] Enable TestPrism#test_truncated_source_line 2024-05-20 12:28:37 -04:00