Commit graph

20692 commits

Author SHA1 Message Date
Hiroshi SHIBATA
b0d3771bce Make benchmark as bundled gems 2025-01-10 10:19:39 +09:00
Hiroshi SHIBATA
0c3dca6266 Make pstore as bundled gems 2025-01-10 10:19:39 +09:00
Nobuyoshi Nakada
073c4e1cc7
[Feature #6012] Extend source_location for end position and columns 2025-01-09 20:21:41 +09:00
Nobuyoshi Nakada
dfe6b7c02e
[Bug #21018] Show invalid command line option more properly 2025-01-09 19:26:20 +09:00
ydah
c721301132 Implement FOR NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e "for a in b do end"
@ ProgramNode (location: (1,0)-(1,17))
+-- locals: [:a]
+-- statements:
    @ StatementsNode (location: (1,0)-(1,17))
    +-- body: (length: 1)
        +-- @ ForNode (location: (1,0)-(1,17))
            +-- index:
            |   @ LocalVariableTargetNode (location: (1,4)-(1,5))
            |   +-- name: :a
            |   +-- depth: 0
            +-- collection:
            |   @ CallNode (location: (1,9)-(1,10))
            |   +-- CallNodeFlags: variable_call, ignore_visibility
            |   +-- receiver: nil
            |   +-- call_operator_loc: nil
            |   +-- name: :b
            |   +-- message_loc: (1,9)-(1,10) = "b"
            |   +-- opening_loc: nil
            |   +-- arguments: nil
            |   +-- closing_loc: nil
            |   +-- block: nil
            +-- statements: nil
            +-- for_keyword_loc: (1,0)-(1,3) = "for"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- in_keyword_loc: (1,6)-(1,8) = "in"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- do_keyword_loc: (1,11)-(1,13) = "do"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- end_keyword_loc: (1,14)-(1,17) = "end"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2025-01-09 18:24:56 +09:00
Kevin Newton
96f23306f0 [ruby/prism] Revert "Reject pattern match with unexpected double splat inside array"
51e7c84124
2025-01-08 20:42:35 +00:00
Kevin Newton
c4534c9fe8 [ruby/prism] Handle escapes in named capture names
b4b7a69ce7
2025-01-08 20:36:06 +00:00
ydah
500a87756f [ruby/prism] Reject pattern match with unexpected double splat inside array
`a => [-2**b]` should be SyntaxError

Fixes: https://github.com/ruby/prism/issues/3381

ae8e83b389
2025-01-08 17:23:51 +00:00
Jeremy Evans
e0d600ec19
Avoid opt_aset_with optimization inside multiple assignment
Previously, since the opt_aset_with optimization was introduced,
use of the opt_aset_with optimization inside multiple assignment
would result in a segfault or incorrect instructions.

Fixes [Bug #21012]

Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
2025-01-08 08:49:51 -08:00
Kazuki Yamaguchi
e728170043 [ruby/rdoc] Finalize RDoc::Options before calling
RDoc::RDoc#parse_files
(https://github.com/ruby/rdoc/pull/1274)

Commit 6cf6e1647b, which went to v6.5.0, changed `RDoc::Options#parse`
to not call `#finish` in it. While the commit adjusted other call sites,
it missed `lib/rdoc/rubygems_hook.rb`.

`RDoc::Options#finish` prepares the include paths for `:include:`
directives. This has to be done before starting to parse sources.

I think this should fix https://github.com/ruby/net-http/issues/193 +
https://github.com/ruby/net-http/pull/194.

d62da8ca09
2025-01-08 16:17:57 +00:00
Hiroshi SHIBATA
a4528f60e5 Omit Psych_Unit_Tests if ostruct is not available 2025-01-08 17:12:19 +09:00
Hiroshi SHIBATA
599a0601f6 Switch to use ostruct to open3 with suggestion test 2025-01-08 17:12:19 +09:00
Hiroshi SHIBATA
9f5ca6332b Refactor to omit JSON::GenericObject tests 2025-01-08 17:12:19 +09:00
Hiroshi SHIBATA
6bff923d2f Rewrite OpenStruct to dummy response class 2025-01-08 17:12:19 +09:00
Hiroshi SHIBATA
4da545ddf3 Use erb instead of ostruct for test_frozen_loaded_features 2025-01-08 17:12:19 +09:00
Hiroshi SHIBATA
5f4be3ad7e Make ostruct as bundled gems 2025-01-08 17:12:19 +09:00
Nobuyoshi Nakada
b81db531b2
[Bug #21011] nd_value is NULL in massign 2025-01-08 13:26:14 +09:00
Kevin Newton
1a06bee027 Do not intern invalid symbols in eval parse
When the inner code cannot represent the name of the locals in the
outer code, do not bother putting them into the constant pool as
they will not be referenced.

Fixes [Bug #20992]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2025-01-07 22:30:16 -05:00
Aaron Patterson
63723c8d59 Correctly set node_id on iseq location
The iseq location object has a slot for node ids.  parse.y was correctly
populating that field but Prism was not. This commit populates the field
with the ast node id for that iseq

[Bug #21014]
2025-01-07 17:08:43 -08:00
eileencodes
ad96c5a729 [ruby/prism] Throw syntax error for endless method with []=
Prism shoudld throw a syntax error for endless methods when the method
name uses brackets. Previously it would not. This matches the behavior
of parse.y.

Fixes https://bugs.ruby-lang.org/issues/21010

43c16a89ef
2025-01-07 19:35:01 +00:00
Earlopain
60f235ab1f [ruby/prism] Move a parser translator test to a known failure
That issue is exactly about what this test file contains:
A single-quoted heredocs with backslashes

4820a44c7b
2025-01-07 14:25:38 +00:00
Nobuyoshi Nakada
b176d4f52e
[Bug #21008] Normalize before sum to float
After switching to `Float`-mode when summing `Numeric` objects,
normalization for `Float` is still needed.
2025-01-07 11:38:51 +09:00
tomoya ishida
8fb17f86d7
[Bug #21006] Fix defined_expr compilation of method call with parenth… (#12518)
[Bug #21006] Fix defined_expr compilation of method call with parenthesized receiver
2025-01-07 05:06:02 +09:00
Mari Imaizumi
5698f4f2e1 [ruby/reline] Enter newline if cursor position is middle of input
(https://github.com/ruby/reline/pull/802)

* Enter newline if cursor position is middle of input

* Add ed_force_submit to allow input confirmation on non-final lines

8ef534e904
2025-01-06 19:21:09 +00:00
Kevin Newton
31905d9e23 Allow escaping from ensures through next
Fixes [Bug #21001]
2025-01-06 13:18:22 -05:00
Kazuki Yamaguchi
a61c16ba42 [ruby/openssl] pkey: simplify X25519/Ed25519 test cases
When these test cases were written, we did not know the exact OpenSSL
and LibreSSL version number in which they would be implemented. Now that
we know it, we can use that information to ensure the tests are run
whenever they should be.

 - OpenSSL 1.1.0 added X25519 support
 - OpenSSL 1.1.1 added Ed25519 support and
   EVP_PKEY_new_raw_private_key()
 - LibreSSL 3.7.0 added X25519 and Ed25519 support in EVP_PKEY and
   EVP_PKEY_new_raw_private_key()
 - LibreSSL 3.8.1 allowed ASN1_item_sign() to use Ed25519

6cb6663c91
2025-01-06 17:07:57 +00:00
Kazuki Yamaguchi
3da850104e [ruby/openssl] pkey: fix test case for new_raw_*key
Method names must start with "test_" to run.

fed9d09b76
2025-01-06 17:07:57 +00:00
Kazuki Yamaguchi
ff708f86fa [ruby/openssl] pkey/ec: use heredoc for invalid key example in test cases
test/openssl/fixtures/pkey/p256_too_large.pem and p384_invalid.pem are
invalid keys where the encoded public key doesn't match the private key.
They are only useful for test cases for OpenSSL::PKey::EC#check_key and
will not be reused elsewhere. Let's directly include the PEM encoding
as a heredoc for clarity.

p384_invalid.pem is dropped because it is redundant.

2f807ff30f
2025-01-06 17:07:56 +00:00
Kazuki Yamaguchi
f0095413a5 [ruby/openssl] x509cert: simplify test cases for Certificate.load_file
Remove files from test/openssl/fixtures/pkey/ which are not pkeys.
The test cases for OpenSSL::X509::Certificate.load_file can simply use
issue_cert and Tempfile.

11216b8bec
2025-01-06 17:07:56 +00:00
samuel40791765
5412501e36 [ruby/openssl] pkey: Use openssl generated pkcs8 key instead
6a6fac9958
2025-01-06 14:04:58 +00:00
Junichi Ito
c8e3d745fa Use a single quote instead of a backtick for error messages
Fix https://bugs.ruby-lang.org/issues/20977
2025-01-05 20:50:53 -05:00
Kevin Newton
2a1cff40f5 Do not warn unused block when using forwarding
Fixes [Bug #21003]
2025-01-05 19:56:21 -05:00
Earlopain
c037f5a28c [ruby/prism] Fix parser translator ast for heredoc with written newlines
Heredocs that contain "\\n" don't start a new string node.

61d9d3a15e
2025-01-05 18:12:44 +00:00
Stan Lo
9552bd590c
Sync IRB to 3e6c12b (#12486)
Sync IRB to 3e6c12b174c0a961d8065eae22f6c4afc7b2c3e8
2025-01-05 18:42:27 +09:00
tomoya ishida
a70206c439 [ruby/reline] Refactor utf-8 strings and invalid strings in test
code
(https://github.com/ruby/reline/pull/800)

* Remove invalid encoding string "\M-[char]" from test code, remove unused code/arg/options

* Omit unicode unnoralized input test in non-utf8 testcase

* Remove helper method and constant no longer used in testcode

* Change key binding test to use realistic bytes instead of invalid byte sequence

* Remove invalid byte sequence input from rendering test

yamatanooroti handles invalid byte sequence input "\M-[char]" and converts it to "\e[char]"
We don't need to use these invalid byte sequence and rely on the hack implemented in yamatanooroti

f09e7b154c
2025-01-05 06:57:25 +00:00
tomoya ishida
9a15672614 [ruby/reline] Fix bracketed paste and scrolling bug
(https://github.com/ruby/reline/pull/801)

* Fix set_pasting_state bug with bracketed paste

* Fix rendered cursor_y caching in case of rendering the screen without scroll_into_view

c5d5c444df
2025-01-05 04:57:23 +00:00
Peter Zhu
dfc9e978fb [Bug #21004] Fix memory leak with "it" in parse.y
Parsing `-> do it end` in parse.y leaks memory. We can see this in the
Valgrind output:

    56 bytes in 1 blocks are definitely lost in loss record 1 of 6
        at 0x484E0DC: calloc (vg_replace_malloc.c:1675)
        by 0x188970: calloc1 (default.c:1472)
        by 0x188970: rb_gc_impl_calloc (default.c:8208)
        by 0x188970: ruby_xcalloc_body (gc.c:4598)
        by 0x18B8BC: ruby_xcalloc (gc.c:4592)
        by 0x21DCCA70: new_locations_lambda_body (ripper.y:12844)
        by 0x21DCCA70: ripper_yyparse (ripper.y:5194)
        by 0x21DDA521: rb_ruby_ripper_parse0 (ripper.y:15798)
2025-01-05 09:06:12 +09:00
Peter Zhu
9d7ba7848f Suppress warnings for flip-flop in test_ast.rb
There are warnings emitted from test_flip2_locations and test_flip3_locations.
This commit changes ast_parse to suppress all warnings.

    warning: integer literal in flip-flop
    warning: string literal in flip-flop
2025-01-04 17:53:33 -05:00
Alan Wu
c71addc522 YJIT: Fix crash when yielding keyword arguments
Previously, the code for dropping surplus arguments when yielding
into blocks erroneously attempted to drop keyword arguments when there
is in fact no surplus arguments. Fix the condition and test that
supplying the exact number of keyword arguments as require compiles
without fallback.
2025-01-04 12:53:20 -05:00
ydah
c936699431 Implement FLIP3 NODE locations 2025-01-04 20:27:40 +09:00
ydah
24653430cd Implement FLIP2 NODE locations 2025-01-04 20:27:40 +09:00
ydah
61c4907458 Implement DOT3 NODE locations 2025-01-04 20:27:40 +09:00
ydah
88da6856a3 Implement DOT2 NODE locations 2025-01-04 20:27:40 +09:00
ydah
5fcc3ab534 Implement REGX NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e '/foo/'
@ ProgramNode (location: (1,0)-(1,5))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,5))
    +-- body: (length: 1)
        +-- @ RegularExpressionNode (location: (1,0)-(1,5))
            +-- RegularExpressionFlags: forced_us_ascii_encoding
            +-- opening_loc: (1,0)-(1,1) = "/"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- content_loc: (1,1)-(1,4) = "foo"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- closing_loc: (1,4)-(1,5) = "/"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- unescaped: "foo"
```
2025-01-04 13:53:13 +09:00
ydah
fa2517451e Implement LAMBDA NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e "-> (a, b) do foo end"
@ ProgramNode (location: (1,0)-(1,20))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,20))
    +-- body: (length: 1)
        +-- @ LambdaNode (location: (1,0)-(1,20))
            +-- locals: [:a, :b]
            +-- operator_loc: (1,0)-(1,2) = "->"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- opening_loc: (1,10)-(1,12) = "do"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- closing_loc: (1,17)-(1,20) = "end"
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: (snip)
```
2025-01-04 13:52:35 +09:00
ydah
607b1b3d76 Implement YIELD NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e 'def foo; yield end'
@ ProgramNode (location: (1,0)-(1,18))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,18))
    +-- body: (length: 1)
        +-- @ DefNode (location: (1,0)-(1,18))
            +-- name: :foo
            +-- name_loc: (1,4)-(1,7) = "foo"
            +-- receiver: nil
            +-- parameters: nil
            +-- body:
            |   @ StatementsNode (location: (1,9)-(1,14))
            |   +-- body: (length: 1)
            |       +-- @ YieldNode (location: (1,9)-(1,14))
            |           +-- keyword_loc: (1,9)-(1,14) = "yield"
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |           +-- lparen_loc: nil
                        ^^^^^^^^^^^^^^^^^^^
            |           +-- arguments: nil
            |           +-- rparen_loc: nil
                        ^^^^^^^^^^^^^^^^^^^
            +-- locals: []
            +-- def_keyword_loc: (1,0)-(1,3) = "def"
            +-- operator_loc: nil
            +-- lparen_loc: nil
            +-- rparen_loc: nil
            +-- equal_loc: nil
            +-- end_keyword_loc: (1,15)-(1,18) = "end"
```
2025-01-04 07:34:49 +09:00
ydah
4c19201142 Implement EVSTR NODE locations
The following Location information has been added This is the information required for parse.y to be a universal parser:

```
❯ ruby --parser=prism --dump=parsetree -e '"#{foo}"'
@ ProgramNode (location: (1,0)-(1,8))
+-- locals: []
+-- statements:
    @ StatementsNode (location: (1,0)-(1,8))
    +-- body: (length: 1)
        +-- @ InterpolatedStringNode (location: (1,0)-(1,8))
            +-- InterpolatedStringNodeFlags: nil
            +-- opening_loc: (1,0)-(1,1) = "\""
            +-- parts: (length: 1)
            |   +-- @ EmbeddedStatementsNode (location: (1,1)-(1,7))
            |       +-- opening_loc: (1,1)-(1,3) = "\#{"
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |       +-- statements:
            |       |   @ StatementsNode (location: (1,3)-(1,6))
            |       |   +-- body: (length: 1)
            |       |       +-- @ CallNode (location: (1,3)-(1,6))
            |       |           +-- CallNodeFlags: variable_call, ignore_visibility
            |       |           +-- receiver: nil
            |       |           +-- call_operator_loc: nil
            |       |           +-- name: :foo
            |       |           +-- message_loc: (1,3)-(1,6) = "foo"
            |       |           +-- opening_loc: nil
            |       |           +-- arguments: nil
            |       |           +-- closing_loc: nil
            |       |           +-- block: nil
            |       +-- closing_loc: (1,6)-(1,7) = "}"
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            +-- closing_loc: (1,7)-(1,8) = "\""
```
2025-01-04 07:34:25 +09:00
tomoya ishida
fa0478d355 [ruby/reline] Refactor handling key in LineEditor
(https://github.com/ruby/reline/pull/799)

Simplify the complicated flow of waiting_proc, wrap_method_call and run_for_operation

72c0ec0425
2025-01-03 14:27:44 +00:00
ydah
c22b0598b0 Implement SUPER NODE locations 2025-01-03 23:03:04 +09:00
Martin Dürst
27e61e2df7 Speed up initial test creation in test_case_comprehensive.rb:
- Change generate_case_mapping_tests to
  generate_single_byte_case_mapping_tests
  (all encodings using this method happen to be single-byte)
- Change precalculation of codepoints by converting from
  specific encoding, not from Unicode. This reduces creation time.
(See https://github.com/ruby/ruby/pull/7425 for a related proposal
and some additional comments.)
2025-01-03 21:28:47 +09:00