Commit graph

14659 commits

Author SHA1 Message Date
Kevin Newton
26507b92e0 [ruby/prism] Include BSDmakefile
1fe507fe3d
2024-03-04 16:26:36 +00:00
Kevin Newton
5856ea3fd1 [ruby/prism] Fix up some minor parser incompatibilities
c6c771d1fa
2024-03-04 14:39:52 +00:00
Yuta Saito
71d511615b mkmf.rb: Define missing POSTLINK variable in generated Makefile
The `POSTLINK` variable had been used in the `LINK_SO` variable, which
is used to link shared extension libraries. However, the `POSTLINK`
variable had not been defined in the generated Makefile, so extension
libraries were not properly post-processed. It was not a critical issue
for the existing `POSTLINK` usage for darwin platforms, but it would be
a problem for Wasm/WASI platform, which requires *mandatory*
post-processing for shared extension libraries.
2024-03-02 17:07:37 +09:00
Stan Lo
57ca5960ad [ruby/irb] Restructure workspace management
(https://github.com/ruby/irb/pull/888)

* Remove dead irb_level method

* Restructure workspace management

Currently, workspace is an attribute of IRB::Context in most use cases.
But when some workspace commands are used, like `pushws` or `popws`, a
workspace will be created and used along side with the original workspace
attribute.

This complexity is not necessary and will prevent us from expanding
multi-workspace support in the future.

So this commit introduces a @workspace_stack ivar to IRB::Context so IRB
can have a more natural way to manage workspaces.

* Fix pushws without args

* Always display workspace stack after related commands are used

61560b99b3
2024-03-01 15:51:29 +00:00
Nobuyoshi Nakada
5d76fe6b2a [ruby/optparse] Invoke pager for --help
77dccce37c
2024-03-01 07:10:08 +00:00
Kasumi Hanazuki
2508a79699 [ruby/resolv] Implement CAA resource record
This patch implements handling of CAA resource records defined by [RFC8659].

- There are no known deployment of CAA records outside of IN (Internet),
  but the RFC does not state that CAA records are class-specific.
  Thus `CAA` class is defined as a class-independent RRType.
- `CAA` class stores `flags` field (a 1-octet bitset) as an Integer.
  In this way it's easier to ensure the encoded RR is in the valid wire format.

[RFC8659]: https://datatracker.ietf.org/doc/html/rfc8659

cfc4de75e3

Co-authored-by: aeris <aeris@imirhil.fr>
2024-02-29 20:55:26 +00:00
Benoit Daloze
6075f67ae6 [ruby/prism] Tweak wording for Prism::BACKEND
* TruffleRuby does support C extensions but FFI is faster there.

d211a87691
2024-02-29 19:24:04 +00:00
Yuta Saito
57f014b2fa Use configured LD for linking enc and ext libraries
"AR" was well propagated to the enc.mk and mkmf, but "LD" was not. This
caused the dynamic libraries to be linked with a linker found in the PATH,
which could be different from the one used in the Ruby build process.
This is especially important for cross-compilation, where the host
linker may not be compatible with the target system. (e.g. WebAssembly)
2024-03-01 03:16:23 +09:00
Kevin Newton
50e999c56d [ruby/prism] Command line options as a bitset
369ffbd57e
2024-02-29 12:05:19 -05:00
Kevin Newton
cd8d1018bb [ruby/prism] Resync RBI and test it in CI
4ef4032774
2024-02-29 16:29:16 +00:00
Koichi ITO
f8dd2342bf [ruby/prism] Fix an incorrect parsing for Prism::Translation::Parser
This PR fixes an incorrect parsing for `Prism::Translation::Parser`
when one-line pattern mathing with Ruby 2.7 runtime.

## Expected

Parsing should be done based on the specified Ruby parsing version,
independent of the Ruby runtime version. When parsing for Ruby 3.3,
it should return `:match_pattern_p` node:

```console
$ ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("foo in bar")'
ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-darwin19]
s(:match_pattern_p,
s(:send, nil, :foo),
  s(:match_var, :bar))
```

## Actual

When parsing with Ruby 2.7 runtime, `match_pattern` node is returned,
even though it is expected to parse for Ruby 3.3:

```console
$ ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("foo in bar")'
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-darwin19]
s(:match_pattern,
s(:send, nil, :foo),
  s(:match_var, :bar))
```

The cause was the use of `RUBY_VERSION` for condition logic,
which made it dependent on runtime Ruby version.
`Prism::Translation::Parser` supports parsing for Ruby 3.3+.
Therefore, the condition for parsing Ruby 2.7, which is not supported, is being removed.

## Background

Found due to incompatibility with RuboCop's `Layout/SpaceAroundKeyword` and `Style/TernaryParentheses` cops.

e752e251d2
2024-02-29 16:06:40 +00:00
Koichi ITO
7c4bf61a35 [ruby/prism] Follow RuboCop's parser engine support
With the introduction of `Prism::Translation::Parser` to RuboCop (RuboCop AST),
the number of arguments for `RuboCop::AST::ProcessedSource#parser_class` internal API will be changed:
https://github.com/rubocop/rubocop-ast/pull/277

## Before

As a result, the following error will occur starting from the next release of RuboCop AST (< 1.30.0) :

```console
$ bundle exec ruby -rrubocop/ast -rprism -rprism/translation/parser/rubocop -ve \
"p RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.33).ast"
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
/Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser/rubocop.rb:25:in `parser_class':
wrong number of arguments (given 2, expected 1) (ArgumentError)
        from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:309:in `create_parser'
        from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:219:in `parse'
        from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:47:in `initialize'
        from -e:1:in `new'
        from -e:1:in `<main>'
```

## After

This PR prevents the above error by updating the monkey patch to support the new argument:

```console
$ bundle exec ruby -rrubocop/ast -rprism -rprism/translation/parser/rubocop -ve \
"p RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.33).ast"
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
s(:int, 42)
```

Moreover, to ensure compatibility with the existing RuboCop AST, conditional logic
has been implemented to maintain backward compatibility.

8a6909f4d5
2024-02-27 20:09:42 +00:00
Kevin Newton
3ca8b4aee0 [ruby/prism] Support -p, -n, -a, and -l command line options
959eb506ca
2024-02-27 04:22:39 +00:00
Josef Šimánek
bfb2dc8acf [rubygems/rubygems] Warn on empty or open required_ruby_version specification attribute.
e4bb33747a
2024-02-27 12:33:45 +09:00
Nobuyoshi Nakada
316d1e1014 [ruby/tmpdir] Fix for environment without git
3f1f2260eb
2024-02-27 01:31:50 +00:00
Nobuyoshi Nakada
cbbb98ba5e [ruby/tempfile] Fix for environment without git
f224164979
2024-02-27 01:31:12 +00:00
Hiroshi SHIBATA
81dded1044 [rubygems/rubygems] Skip to load vendored libraries if it's already loaded
3f5093fac9
2024-02-26 22:04:08 +00:00
Hiroshi SHIBATA
c342726568 [rubygems/rubygems] Keep compatiblity for RG 3.5
d004e36c44
2024-02-26 22:04:08 +00:00
Hiroshi SHIBATA
8b22198ee9 [rubygems/rubygems] Use wrapper file for vendored tsort
93514afa28
2024-02-26 22:04:07 +00:00
Hiroshi SHIBATA
d220d273aa [rubygems/rubygems] Use renamed file on bundler
d198ec36f2
2024-02-26 22:04:05 +00:00
Hiroshi SHIBATA
d2da774f87 [rubygems/rubygems] Rename wrapper files for vendored libraries with 'vendored_' prefix
cfc908c8c1
2024-02-26 22:04:04 +00:00
Kevin Newton
1ce3d9acbf [ruby/prism] Fix xstring heredoc parser translator
4e0f703975
2024-02-26 14:48:17 +00:00
Kevin Newton
99d0f687fc [ruby/prism] Fix parser translator for pinned expression
eeae07193b
2024-02-26 14:35:00 +00:00
Kevin Newton
af3145bb24 [ruby/prism] Handle negated numeric in parser translation
5877a95be4
2024-02-26 14:26:53 +00:00
Nobuyoshi Nakada
dddf62426b [ruby/tempfile] Use IO.popen to list files
- Redirect `git ls-files` 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.

ac5bab8c7a
2024-02-26 15:56:28 +09:00
Nobuyoshi Nakada
38e3ad2675
Update gemspec according to the recent bundler template 2024-02-26 15:55:17 +09:00
Stan Lo
c976cb52a2 [ruby/irb] Add help messages to show_source and show_doc
commands
(https://github.com/ruby/irb/pull/887)

* Add help message to the show_source command

* Add help message to the show_doc command

06f43aadb3
2024-02-25 15:22:33 +00:00
Stan Lo
898f30f8bd [ruby/irb] Refactor IRB::Context#prompting
(https://github.com/ruby/irb/pull/889)

7b323ee514
2024-02-25 15:21:00 +00:00
Adam Daniels
c16b507563 [ruby/tmpdir] [DOC] require inside each method on Dir
(https://github.com/ruby/tmpdir/pull/31)

a1ec977923
2024-02-25 08:36:42 +00:00
Nobuyoshi Nakada
c0c56d1714 [ruby/tmpdir] Use IO.popen to list files
- Redirect `git ls-files` 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.

f505e3f7cb
2024-02-25 08:32:09 +00:00
Stan Lo
2c1b7bc51c [ruby/reline] Bump version to v0.4.3
(https://github.com/ruby/reline/pull/642)

5137a3f3af
2024-02-25 08:07:07 +00:00
Stan Lo
2721a64e41 [ruby/reline] Use gray and white as the default dialog theme
(https://github.com/ruby/reline/pull/637)

I think this has a few benefits:

1. Most terminal themes generally don't change or pick similar colors
   for their black and white colors, so it's more likely to be consistent
    across terminals/themes.
2. They don't have the potential color-blind issues that other color options
   may have.
3. We won't need additional changes for no color mode.

6579a0a737
2024-02-25 07:08:34 +00:00
Nobuyoshi Nakada
7356067b73 [ruby/tmpdir] Update gemspec according to the recent bundler template
4ef7bc4f2a
2024-02-25 05:04:12 +00:00
Nobuyoshi Nakada
012a0b9125 [ruby/resolv] Simplify adding new entries
081b8df705
2024-02-25 04:39:22 +00:00
Nobuyoshi Nakada
30b99868f9 [ruby/resolv] Treat hostname as same as aliases
fa812d6454
2024-02-25 04:39:22 +00:00
Kevin Newton
804b2a3787 [ruby/prism] Rebase against main
813e20d449
2024-02-24 03:39:29 +00:00
Gopal Patel
aa8841405b [ruby/prism] Less code modifications. More steep:ignore for now
7905bdbf83
2024-02-24 03:39:28 +00:00
Gopal Patel
dfee033746 [ruby/prism] Replace awkward code changes with steep:ignore
Also remove RBS for currently ignored files. Will follow-up when those
check fully in later PRs.

2cae58f86d
2024-02-24 03:39:28 +00:00
Gopal Patel
66565e36ea [ruby/prism] Add documentation for Location#source!
467e1cc2c4
2024-02-24 03:39:26 +00:00
Gopal Patel
8fa1843523 [ruby/prism] Relax Location#source to be optional
9f00fe7510
2024-02-24 03:39:26 +00:00
Gopal Patel
bfbaafbd9c [ruby/prism] Make rake check_annotations verify public RBS
db78eef6a2
2024-02-24 03:39:26 +00:00
Gopal Patel
ca8a626586 [ruby/prism] Fix my RipperCompat logic mistake from expansion for steep flow analysis
f71a390c12
2024-02-24 03:39:25 +00:00
Gopal Patel
935d4fab62 [ruby/prism] Remove Ripper from public RBS, type-assert remaining issues
5fda7a0760
2024-02-24 03:39:23 +00:00
Gopal Patel
7556fd937c [ruby/prism] Split private types
0209d093ec
2024-02-24 03:39:22 +00:00
Gopal Patel
46fe3dc799 [ruby/prism] Fix IgnoredNewlineToken comparison of Ripper::Lexer::State
8c9502f61b
2024-02-24 03:39:20 +00:00
Gopal Patel
b9b0712556 [ruby/prism] Use steep to type check RBS and Ruby files
eabed9f4fd
2024-02-24 03:39:19 +00:00
Kevin Newton
ec6532b458 [ruby/prism] Add some encoding debugging to make testing easier
0c042561c6
2024-02-23 20:02:19 +00:00
Kevin Newton
a38cc177d2 [ruby/prism] Duplicated when clauses
865b0d5fbe
2024-02-23 13:25:31 -05:00
Akira Matsuda
73dd3ce03e [ruby/ipaddr] Prefer String#start_with? over Regexp.match
054fe12ec4
2024-02-23 17:56:08 +00:00
Akira Matsuda
6ad52e336d [ruby/ipaddr] String#split seems to be faster than capturing digits with Regexp
e0feb0708b
2024-02-23 17:55:33 +00:00