Commit graph

20692 commits

Author SHA1 Message Date
Peter Zhu
f1e32914eb [ruby/mmtk] Add mmtk_worker_count to GC.config
836a9059cb
2025-01-14 20:59:39 +00:00
Earlopain
56242ba495 Better handle regexp in the parser translator
Turns out, it was already almost correct. If you disregard \c and \M style escapes, only a single character is allowed to be escaped in a regex so most tests passed already.

There was also a mistake where the wrong value was constructed for the ast, this is now fixed.
One test fails because of this, but I'm fairly sure it is because of a parser bug. For `/\“/`, the backslash is supposed to be removed because it is a multibyte character. But tbh,
I don't entirely understand all the rules.

Fixes more than half of the remaining ast differences for rubocop tests
2025-01-14 20:33:11 +00:00
Kevin Newton
51d3d6ac8c [ruby/prism] Support forwarding flags on scopes
When parent scopes around an eval are forwarding parameters (like
*, **, &, or ...) we need to know that information when we are in
the parser. As such, we need to support passing that information
into the scopes option. In order to do this, unfortunately we need
a bunch of changes.

The scopes option was previously an array of array of strings.
These corresponded to the names of the locals in the parent scopes.
We still support this, but now additionally support passing in a
Prism::Scope instance at each index in the array. This Prism::Scope
class holds both the names of the locals as well as an array of
forwarding parameter names (symbols corresponding to the forwarding
parameters). There is convenience function on the Prism module that
creates a Prism::Scope object using Prism.scope.

In JavaScript, we now additionally support an object much the same
as the Ruby side. In Java, we now have a ParsingOptions.Scope class
that holds that information. In the dump APIs, these objects in all
3 languages will add an additional byte for the forwarding flags in
the middle of the scopes serialization.

All of this is in service of properly parsing the following code:

```ruby
def foo(*) = eval("bar(*)")
```

21abb6b7c4
2025-01-14 20:31:38 +00:00
Peter Zhu
f5fa1ee5f6 [ruby/mmtk] Exit with error message if MMTK_PLAN is invalid
79ce2008a3
2025-01-14 17:17:44 +00:00
Alan Wu
1adcd960e2 Add tests for Proc#parameters on it blocks
[Bug #20955]
2025-01-14 12:09:22 -05:00
Peter Zhu
2bcbc80fa2 [ruby/mmtk] Exit with error message if MMTK_HEAP_MODE is invalid
c8b1f4c156
2025-01-14 17:07:21 +00:00
Peter Zhu
f627e05d14 [ruby/mmtk] Add tests for when MMTK_HEAP_MIN >= MMTK_HEAP_MAX
65b34b5e86
2025-01-14 17:07:21 +00:00
Peter Zhu
e2f0769ca2 [ruby/mmtk] Also test invalid values for MMTK_HEAP_MIN and MMTK_HEAP_MAX
90f1aa8d76
2025-01-14 17:07:20 +00:00
Kevin Newton
b076e9b7ac Remove incorrectly committed snapshots 2025-01-14 11:46:11 -05:00
Peter Zhu
cf4d848cad [ruby/mmtk] Add framework for tests
6d94549fc7
2025-01-14 16:18:52 +00:00
Kevin Newton
12fa76b3e5 [ruby/prism] Fix parse.y translation for locals test
c8037dfaed
2025-01-14 16:01:46 +00:00
Earlopain
23fc0fc22d [ruby/prism] Be a bit stricter when comparing parser translator tokens
When there were more actual tokens than expected tokens, the test would still pass.

Now it's possible to receive an assertion like this:
```
expected: []
actual: [:tNL, [nil, #<Parser::Source::Range comment_single.txt 8...9>]]
<[]> expected but was
<[:tNL, [nil, #<Parser::Source::Range comment_single.txt 8...9>]]>
```

e9e9a48e43
2025-01-14 15:36:28 +00:00
Justin Collins
d0c493df7d [ruby/prism] Fix block parameters and it for RubyParser
7a93a307ac
2025-01-14 15:33:02 +00:00
Kevin Newton
713f31872a [ruby/prism] Freeze AST option
To make it so that you can pass `freeze: true` to Prism parse
methods and get back a deeply-frozen AST that is Ractor-
shareable.

8e6a93b2d2
2025-01-14 15:32:39 +00:00
Kazuki Yamaguchi
1b515d1c37 [ruby/openssl] ssl: update test_verify_hostname_on_connect for LibreSSL
This reverts the change made to this test case in commit a0e98d48c9
(Enhance TLS 1.3 support on LibreSSL 3.2/3.3, 2020-12-03).

Part of the test case was skipped on LibreSSL because LibreSSL 3.2.2
introduced a stricter check during creation of the extension. The check
was then relaxed in LibreSSL 3.4.0.

187b176ecd
2025-01-14 12:38:17 +00:00
Kazuki Yamaguchi
0fb64bda9b [ruby/openssl] Require LibreSSL 3.9 or later
Drop support for LibreSSL 3.1-3.8. LibreSSL 3.8 has reached its EOL in
2024-10.

f33d611f9f
2025-01-14 12:38:16 +00:00
Jean Boussier
4f79485889 [ruby/openssl] Refactor buffer usage to only use append_as_bytes
28f2901c48
2025-01-14 11:54:47 +00:00
Jean Boussier
599fbeaffa [ruby/json] Refactor JSON::Ext::Parser to split configuration and parsing state
Ref: https://github.com/ruby/json/pull/718

The existing `Parser` interface is pretty bad, as it forces to
instantiate a new instance for each document.

Instead it's preferable to only take the config and do all the
initialization needed, and then keep the parsing state on the
stack on in ephemeral memory.

This refactor makes the `JSON::Coder` pull request much easier to
implement in a performant way.

c8d5236a92

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2025-01-14 09:08:02 +01:00
Hiroshi SHIBATA
382277f9bf [ruby/yaml] We should load rubygems for optional pstore gem
d32dc11205
2025-01-14 04:36:25 +00:00
Dmitrii
f1f81e8615 [ruby/fiddle] add regex for bool parsing & test struct w/ bool
parsing
(https://github.com/ruby/fiddle/pull/169)

GitHub: fix https://github.com/ruby/fiddle/pull/168

Struct parsing invokes "parse_ctype" on the whole member signature,
which fails if member type is "bool" due to plain string matching for
it. This change updates "bool" type matching to a regexp, so TYPE_BOOL
is correctly parsed for a whole signature like "bool toggle" as well as
just "bool".

---------

71607446d4

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
2025-01-14 12:24:37 +09:00
dependabot[bot]
ed0a213608 [rubygems/rubygems] Bump the rb-sys group across 2 directories with 1 update
Bumps the rb-sys group with 1 update in the /test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib directory: [rb-sys](https://github.com/oxidize-rb/rb-sys).
Bumps the rb-sys group with 1 update in the /test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example directory: [rb-sys](https://github.com/oxidize-rb/rb-sys).

Updates `rb-sys` from 0.9.105 to 0.9.107
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.105...v0.9.107)

Updates `rb-sys` from 0.9.105 to 0.9.107
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.105...v0.9.107)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rb-sys
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rb-sys
...

Signed-off-by: dependabot[bot] <support@github.com>

85156ce286
2025-01-14 12:24:37 +09:00
Peter Zhu
5f3d1eeb55 [ruby/mmtk] Remove accidentally committed files
154a038293
2025-01-13 20:11:06 +00:00
Peter Zhu
f821a127ea [ruby/mmtk] Exit with error message if MMTK_HEAP_MIN is invalid
1d2f7b9cfc
2025-01-13 20:08:20 +00:00
Earlopain
7c0b92a1c6 [ruby/prism] Fix parser translator tokens for %x(#{})
It falsely considered it to be a single backtick command

dd762be590
2025-01-13 18:02:28 +00:00
Alan Wu
6637aa4682 Proc#parameters: Show anonymous optionals as [:opt]
Have this for lead parameters as well as parameters after rest ("post").

[Bug #20974]
2025-01-13 12:58:59 -05:00
Earlopain
0a26a3de89 [ruby/prism] Fix parser translator heredoc dedention with leading interpolation
```rb
<<~F
  foo
#{}
  bar
F
```

has zero common whitespace.

1f3c222a06
2025-01-13 15:43:24 +00:00
Peter Zhu
eab1f02149 [ruby/mmtk] Unskip TestEnv#test_select_bang_in_ractor
b2b83ecadb
2025-01-13 15:25:50 +00:00
Earlopain
566f9463c2 [ruby/prism] Fix parser translator tSPACE tokens for percent arrays
Tests worked around this but the incompatibility is not hard to fix.
This fixes 17 token incompatibilies in tests here that were previously passing

101962526d
2025-01-12 18:54:16 +00:00
Kevin Newton
14b9098459 [ruby/prism] Frozen strings in the AST
8d9d429155
2025-01-12 18:41:42 +00:00
Earlopain
d0deec3ef3 [ruby/prism] Fix parser translator tokens for comment-only file
In https://github.com/ruby/prism/pull/3393 I made a mistake.
When there is no previous token, it wraps around to -1. Oops

Additionally, if a comment has no newline then the offset should be kept as is

3c266f1de4
2025-01-12 18:34:06 +00:00
Nobuyoshi Nakada
f56f3eaae5
[Bug #21030] Fix step for non-numeric range
When the end points of an inclusive range equal, `Range#step` should
yields the element once.
2025-01-13 02:07:05 +09:00
Nobuyoshi Nakada
d9e1a7cdf8
[Bug #21018] Fix for s390x 2025-01-12 23:01:07 +09:00
Earlopain
723f31cf6b [ruby/prism] Fix binary encoding for the parser translator
Skipping detecting the encoding is almost always right, just for binary it should actually happen.

A symbol containing escapes that are invalid
in utf-8 would fail to parse since symbols must be valid in the script encoding.
Additionally, the parser gem would raise an exception somewhere during string handling

fa0154d9e4
2025-01-12 00:49:54 +00:00
Earlopain
70022224b2 [ruby/prism] Better comment token handling for the parser translator
There appear to be a bunch of rules, changing behaviour for
inline comments, multiple comments after another, etc.

This seems to line up with reality pretty closely, token differences for RuboCop tests go from 1129 to 619 which seems pretty impressive

2e1b92670c
2025-01-11 19:09:05 -05:00
Earlopain
9c962ea792 [ruby/prism] Fix parser translator tokens for backslashes in single-quoted strings and word arrays
These are not line continuations. They either should be taken literally,
or allow the word array to contain the following whitespace (newlines in this case)

Before:
```
  0...1: tSTRING_BEG     => "'"
 1...12: tSTRING_CONTENT => "foobar\\\n"
12...16: tSTRING_CONTENT => "baz\n"
16...17: tSTRING_END     => "'"
17...18: tNL             => nil
```

After:
```
  0...1: tSTRING_BEG     => "'"
  1...6: tSTRING_CONTENT => "foo\\\n"
 6...12: tSTRING_CONTENT => "bar\\\n"
12...16: tSTRING_CONTENT => "baz\n"
16...17: tSTRING_END     => "'"
17...18: tNL             => nil
```

b6554ad64e
2025-01-11 19:09:05 -05:00
Earlopain
110461c509 [ruby/prism] Implement more string token escaping in the parser translator
This leaves `\c` and `\M` escaping but I don't understand how these should even work yet. Maybe later.

13db3e8cb9
2025-01-11 19:09:05 -05:00
Earlopain
81079ebfd8 [ruby/prism] Import code samples for Ruby 3.3 from the parser gem
Slightly tweaking the import script becaues of backtrace format changes in Ruby 3.4

Most tests pass in all parsers, with only a handful of failures overall

9b5b785aa4
2025-01-11 19:09:05 -05:00
ydah
ca81142eff [ruby/prism] [Bug #21010] Reject endless method definition of []=
Fixes: https://bugs.ruby-lang.org/issues/20785

192960ce5d
2025-01-11 19:09:05 -05:00
Earlopain
283037f7e3 [ruby/prism] Better handle all kinds of multiline strings in the parser translator
This is a followup to #3373, where the implementation
was extracted

2637007929
2025-01-11 19:09:05 -05:00
Earlopain
80fe9a1c77 [ruby/prism] Better handle multiline interpolated strings in the parser translator
Much of this logic should be shared between interpolated symbols and regexps.
It's also incorrect when the node contains a literal `\\n` (same as for plain string nodes at the moment)

561914f99b
2025-01-11 19:09:05 -05:00
Earlopain
9f38ee11cb [ruby/prism] Fix parser translator ast for empty regex
In that specific case, no string node is emitted

1166db13dd
2025-01-11 19:09:05 -05:00
Earlopain
a234fd516f [ruby/prism] Fix parser translator ast for regex with line continuation
Turns out, the vast majority of work was already done with handling the same for heredocs

I'm confident this should also apply to actual string nodes (there's even a todo for it) but
no tests change if I apply it there too, so I can't say for sure if the logic would be correct.
The individual test files are a bit too large, maybe something else would break that currently passes.

Leaving it for later to look more closely into that.

6bba1c54e1
2025-01-11 19:09:05 -05:00
Earlopain
d1a70014f9 [ruby/prism] Fix parser translator ast when using anonymous forwarding in blocks/lambda
Blocks and lambdas inherit anonymous arguments from the method they are a part of.
They themselves don't allow to introduce new anonymous arguments.
While you can write this:
```rb
def foo(*)
  bar { |**| }
end
```
referecing the new parameter inside of the block will always be a syntax error.

2cbd27e134
2025-01-11 19:09:05 -05:00
Earlopain
7cbaa3b929 [ruby/prism] Fix an incompatibility with the parser translator
The offset cache contains an entry for each byte so it can't be accessed via the string length.

Adds tests for all variants except for this:
```
"fo
o" "ba
’"
```

For some reason, this still has the wrong offset.

a651126458
2025-01-11 19:09:05 -05:00
Kevin Newton
b79152fd22 [ruby/prism] Support 3.5 for version option
6b6aa05bfb
2025-01-11 19:09:05 -05:00
Stan Lo
76b620b341 [ruby/irb] IRB.conf[:SAVE_HISTORY] should handle boolean values
(https://github.com/ruby/irb/pull/1062)

Although not documented, `IRB.conf[:SAVE_HISTORY]` used to accept boolean,
which now causes `NoMethodError` when used.

This commit changes the behavior to accept boolean values and
adds tests for the behavior.

8b1a07b2a8
2025-01-11 14:03:59 +00:00
Stan Lo
039446f601 [ruby/irb] Gracefully handle incorrect command aliases
(https://github.com/ruby/irb/pull/1059)

* Gracefully handle incorrect command aliases

Even if the aliased target is a helper method or does not exist, IRB
should not crash.

This commit warns users in such cases and treat the input as normal expression.

* Streamline command parsing and introduce warnings for incorrect command aliases

9fc14eb74b
2025-01-10 21:29:34 +00:00
Andrew Konchin
8adc96b5ca [ruby/date] Skip tests failing on TruffleRuby
d019ac8186
2025-01-10 15:59:25 +00:00
Hiroshi SHIBATA
3185550623 Make Pstore tests as optional 2025-01-10 10:19:39 +09:00
Hiroshi SHIBATA
cda268d8e9 Make logger as bundled gems 2025-01-10 10:19:39 +09:00