Commit graph

14659 commits

Author SHA1 Message Date
Kevin Newton
7273c4dd60 [ruby/prism] Fix up lambda ripper translation
a3156e60cc
2024-03-06 16:42:48 +00:00
Kevin Newton
db53705acd [ruby/prism] Implement singleton methods for ripper translation
b7cd5c8e74
2024-03-06 16:42:48 +00:00
Kevin Newton
3a7beffd1b [ruby/prism] Consolidate body node visiting in ripper translation
8feb073fe4
2024-03-06 16:42:48 +00:00
Kevin Newton
8f7db7e64c [ruby/prism] Fix up forwarding arguments for ripper translation
9dbad71aa3
2024-03-06 16:42:47 +00:00
Kevin Newton
e97b364adb [ruby/prism] Unary not for ripper translation
149d01f2c9
2024-03-06 16:42:47 +00:00
Kevin Newton
78fe61c95f [ruby/prism] Implement fields for ripper translation
90f8b33fad
2024-03-06 16:42:47 +00:00
Kevin Newton
c2d6bcc81a [ruby/prism] Revisit call nodes for ripper translation
372200f970
2024-03-06 16:42:46 +00:00
Kevin Newton
a0674a5755 [ruby/prism] Fix implementation of [] and []= for ripper translation
d31cf63d45
2024-03-06 16:42:46 +00:00
Kevin Newton
cb11642081 [ruby/prism] Refactor symbol ripper translation
356c97c736
2024-03-06 16:42:46 +00:00
Kevin Newton
47daf71ac0 [ruby/prism] Implement super for ripper translation
18dea6ce64
2024-03-06 16:42:45 +00:00
Kevin Newton
53efae0d63 [ruby/prism] Implement other call nodes for ripper translation
a76744be47
2024-03-06 16:42:45 +00:00
Kevin Newton
b0ee9c8f28 [ruby/prism] Implement index nodes for ripper translation
3fd962f2d3
2024-03-06 16:42:45 +00:00
Kevin Newton
7bcca7177d [ruby/prism] Implement hash patterns for ripper translation
6bd7ae2ed2
2024-03-06 16:42:44 +00:00
Kevin Newton
2cb75b8f17 [ruby/prism] Implement multi target nodes for ripper translation
ceb5a5cf62
2024-03-06 16:42:44 +00:00
Kevin Newton
fabece2507 [ruby/prism] Implement lambdas for ripper translation
602d3d2ccb
2024-03-06 16:42:44 +00:00
Kevin Newton
d719814d82 [ruby/prism] Implement target nodes for ripper translation
c5c8299485
2024-03-06 16:42:43 +00:00
Kevin Newton
1d5f05bd53 [ruby/prism] Implement for loop for ripper translation
2d635ce46b
2024-03-06 16:42:43 +00:00
Kevin Newton
17111084d4 [ruby/prism] Implement endless methods for ripper translation
6611820b7b
2024-03-06 16:42:43 +00:00
Kevin Newton
524e93b84e [ruby/prism] Implement find pattern for ripper translation
ef9dca2a4c
2024-03-06 16:42:42 +00:00
Kevin Newton
3bdb0fecd1 [ruby/prism] Implement case/in for ripper translation
7f5a09f40e
2024-03-06 16:42:42 +00:00
Kevin Newton
c4388e8409 [ruby/prism] Add constant path ripper translation
5e47d8eb67
2024-03-06 16:42:42 +00:00
Kevin Newton
c21a50e596 [ruby/prism] Implement def for ripper translation
a3c8c27c20
2024-03-06 16:42:42 +00:00
Kevin Newton
5422b58457 [ruby/prism] Implement if/unless for ripper translation
57c1dd4859
2024-03-06 16:42:41 +00:00
Kevin Newton
d815d68cbb [ruby/prism] Implement regular expressions for ripper translation
788cf7c528
2024-03-06 16:42:41 +00:00
Kevin Newton
bfa2a08444 [ruby/prism] Start tracking failing fixtures in ripper translation
6285e31ccc
2024-03-06 16:42:41 +00:00
Kevin Newton
139fe4fc63 [ruby/prism] Implement case/when for ripper translation
dfa499d2e9
2024-03-06 16:42:40 +00:00
Kevin Newton
70764bd0be [ruby/prism] Implement sclass for ripper translation
e6e17778f8
2024-03-06 16:42:40 +00:00
Kevin Newton
c947852fa8 [ruby/prism] Implement next for ripper translation
107ffb64a3
2024-03-06 16:42:39 +00:00
Kevin Newton
a47d0f03db [ruby/prism] Implement module for ripper translation
93d06436f7
2024-03-06 16:42:39 +00:00
Kevin Newton
751b4d34bc [ruby/prism] Implement remaining interpolated nodes in ripper translation
129ed94cb5
2024-03-06 16:42:39 +00:00
Kevin Newton
32c22a71e8 [ruby/prism] Implement classes for ripper translation
b2dc35d902
2024-03-06 16:42:38 +00:00
Kevin Newton
f44671b094 [ruby/prism] Implement local variable targets in ripper translation
4e64b9fc53
2024-03-06 16:42:38 +00:00
Kevin Newton
862a188826 [ruby/prism] Implement hashes for ripper translation
57f991a6a6
2024-03-06 16:42:38 +00:00
Kevin Newton
a035f63daa [ruby/prism] Implement even more ripper visitor methods
9a883a474a
2024-03-06 16:42:37 +00:00
Kevin Newton
069568dbfc [ruby/prism] Implement so many ripper visitor methods
336bd7249a
2024-03-06 16:42:37 +00:00
Kevin Newton
b797085c38 [ruby/prism] Implement pre and post execution nodes for ripper
b6927ac714
2024-03-06 16:42:37 +00:00
Kevin Newton
be5376e422 [ruby/prism] Implement even more ripper visitor methods
88b8185075
2024-03-06 16:42:36 +00:00
Kevin Newton
3b7d5efd05 [ruby/prism] Implement many more visitor methods for ripper
b9d762c76a
2024-03-06 16:42:36 +00:00
Kevin Newton
bbaee0b7e4 [ruby/prism] Add stubs for remaining ripper visit methods
4ba9abf664
2024-03-06 16:42:36 +00:00
Kevin Newton
d56e80f07f [ruby/prism] Reconsolidate ripper files
7a277be5fb
2024-03-06 16:42:36 +00:00
Koichi ITO
4d04e1bbef [ruby/prism] Deprecate TargetRubyVersion: 80_82_73_83_77.xx
Prism has been directly supported as a parser engine since RuboCop 1.62:
https://github.com/rubocop/rubocop/releases/tag/v1.62.0

This makes specifying `TargetRubyVersion` with special values like `80_82_73_83_77.33`
using the `prism/translation/parser/rubocop` file unnecessary.
As a result, it would be possible to deprecate this approach.

OTOH, early users might be surprised if `prism/translation/parser/rubocop` were to be suddenly removed.
Therefore, this PR deprecates the parameters related to `prism/translation/parser/rubocop`.

```console
$ bundle exec ruby -rrubocop -rprism/translation/parser/rubocop -e "RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.33).ast"
WARN: Prism is directly supported since RuboCop 1.62. The `prism/translation/parser/rubocop` file is deprecated.
WARN: Setting `TargetRubyVersion: 80_82_73_83_77.33` is deprecated. Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.3` instead.

$ bundle exec ruby -rrubocop -rprism/translation/parser/rubocop -e "RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.34).ast"
WARN: Prism is directly supported since RuboCop 1.62. The `prism/translation/parser/rubocop` file is deprecated.
WARN: Setting `TargetRubyVersion: 80_82_73_83_77.34` is deprecated. Set to `ParserEngine: parser_prism` and `TargetRubyVersion: 3.4` instead.
```

Eventually, it will be possible to remove it at some point.

Regarding documentation, it has been updated to not show the old, discouraged usage but rather
the new way of specifying it in RuboCop.

0e4bc31463
2024-03-06 16:11:07 +00:00
Nobuyoshi Nakada
7d3304ec5f [ruby/time] Exclude unnecessary files from package
4abeaec776
2024-03-06 15:47:31 +00:00
Haroon Ahmed
8f6113a91e [ruby/irb] Add the ability to fetch and load multiple irb files.
(https://github.com/ruby/irb/pull/859)

This allows hierarchy when loading rc files for example both files below
are loaded;

project/.irbrc
~/.irbrc

b53ebc6655

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-03-05 16:07:45 +00:00
cui fliter
226a889dc7
[DOC] fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 18:50:47 +09:00
Hiroshi SHIBATA
8e27c01fbb Reapply "mkmf.rb: Define missing POSTLINK variable in generated Makefile"
This reverts commit 0ae0a0c1c3.
2024-03-05 17:03:30 +09:00
Nobuyoshi Nakada
e1026000af [rubygems/rubygems] Use IO.popen to list files
- Redirect stderr `git ls-files` to null without shelling out.

- When building by `gem`, `__FILE__` is the path name given in the
  command line, or the gemspec file name in the current directory.  In
  that case, comparison it and expanded path never equal.  Compare
  listed file names with the base name of `__FILE__` instead.

5583433dbb
2024-03-05 06:53:20 +00:00
Hiroshi SHIBATA
0ae0a0c1c3 Revert "mkmf.rb: Define missing POSTLINK variable in generated Makefile"
This reverts commit 71d511615b.
2024-03-05 12:08:42 +09:00
Kevin Newton
03a73fdc3d [ruby/prism] Add then keyword loc to when nodes
e1e613df16
2024-03-04 16:40:37 +00:00
Kevin Newton
85fe8b6b9c [ruby/prism] Update lib/prism/translation/parser/compiler.rb
dccfd83bc4
2024-03-04 16:26:47 +00:00
Koichi ITO
a03f92923b [ruby/prism] Fix incompatibility AST for regexp match in Prism::Translation::Parser
This PR fixes the following incompatibility AST for regexp match between Parser gem and Prism:

## Parser gem

Returns an `match_with_lvasgn` node:

```console
$ bundle exec ruby -rparser/ruby33 -ve 'p Parser::Ruby33.parse("/foo/ =~ bar")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
s(:match_with_lvasgn,
  s(:regexp,
    s(:str, "foo"),
    s(:regopt)),
  s(:send, nil, :bar))
```

## Prism (`Prism::Translation::Parser`)

### Before

Returns an `send` node:

```console
$ bundle exec ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("/foo/ =~ bar")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
s(:send,
  s(:regexp,
    s(:str, "foo"),
    s(:regopt)), :=~,
  s(:send, nil, :bar))
```

### After

Returns an `match_with_lvasgn` node:

```console
$ bundle exec ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("/foo/ =~ bar")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
s(:match_with_lvasgn,
  s(:regexp,
    s(:str, "foo"),
    s(:regopt)),
  s(:send, nil, :bar))
```

## Background

Found due to incompatibility with RuboCop's `Performance/EndWith`, `Performance/StringInclude,
and `Performance/StartWith` cops.

## Note

This is the incompatibility when the receiver is a regular expression literal and `=~` is used.
Based on the node name `:match_with_lvasgn`, it appears that Prism's AST becomes more accurate
in cases like `visit_match_write_node` only.

However, as shown in the background, the current behavior of Parser gem is not like this.
Considering compatibility with the published AST of Parser gem, the AST incompatibility will be addressed.

This lvar-injecting feature appears to have not been supported by Parser gem for a long time:
https://github.com/whitequark/parser/issues/69#issuecomment-19506391

There seems to be no indication that it will be supported.

This PR prioritizes AST compatibility between the Parser gem and Prism.
However, it is unclear whether this is the best approach.

dff4abb170
2024-03-04 16:26:46 +00:00