Commit graph

20692 commits

Author SHA1 Message Date
Noah Gibbs
f635b4dd0e [ruby/prism] RipperCompat: add array-refs, assigns, symbols, strings
b771c7f2ec
2024-02-09 19:49:27 +00:00
Jean Boussier
d19d683a35 rb_obj_setup: do not copy RUBY_FL_SEEN_OBJ_ID
[Bug #20250]

We're seting up a new instance, so it never had an associated
object_id.
2024-02-09 17:38:54 +01:00
Nobuyoshi Nakada
db73226bf6 [ruby/optparse] Adjust arguments for lambda-callbacks
Rake uses [lambda] as callbacks.
Calling it without omitted argument raises an `ArgumentError`.

lambda: https://github.com/ruby/rake/blob/master/lib/rake/application.rb#L543

213cb03b59
2024-02-09 19:58:31 +09:00
Nobuyoshi Nakada
2c6767b71e [ruby/optparse] Respect default values in block parameters
Fix https://github.com/ruby/optparse/pull/55

9d53e74aa4
2024-02-09 19:58:19 +09:00
fatkodima
f7a407cabd [ruby/optparse] Fix require_exact to work with options defined as --[no]-something
4e346ad337
2024-02-09 03:31:13 +00:00
Petrik
2a57e6e6ed [ruby/rdoc] Don't document aliases with trailing :nodoc directive
Attribute readers and writers can be marked as `:nodoc` to keep them
undocumented:

```ruby
attr_reader :name # :nodoc:
```

For aliases this behaviour should be the same:

```ruby
alias_method :old :new # :nodoc:
```

30f14e8271
2024-02-09 01:07:17 +00:00
Noah Gibbs
366af4679e [ruby/prism] RipperCompat: support for more features.
* add bin/prism ripper to compare Ripper output
* block arg handling is quirky, do it per-call-site
* block required params
* boolean values
* various assign-operator support
* breaks, early fragile begin/rescue/end
* more fixtures being checked

31732cb720
2024-02-08 16:02:04 +00:00
Peter Zhu
01fd262e62 Fix crash when checking symbol encoding
[Bug #20245]

We sometimes pass in a fake string to sym_check_asciionly. This can crash
if sym_check_asciionly raises because it creates a CFP with the fake
string as the receiver which will crash if GC tries to mark the CFP.

For example, the following script crashes:

    GC.stress = true
    Object.const_defined?("\xC3")
2024-02-08 10:12:56 -05:00
Charles Oliver Nutter
39f2e37ff1
[ruby/strscan] Don't add begin to length for new string slice
(https://github.com/ruby/strscan/pull/87)

Fixes https://github.com/ruby/strscan/pull/86

c17b015c00
2024-02-08 14:43:56 +09:00
Noah Gibbs
5b7baa0486 [ruby/prism] More different block-call syntaxes, support more types of method calls
40cf114a24
2024-02-07 19:42:13 +00:00
Noah Gibbs
73d222e1ef [ruby/prism] Support &. calls and calling with blocks, test with fixtures
e346fa583a
2024-02-07 19:42:13 +00:00
Noah Gibbs
b1310940e3 [ruby/prism] RipperCompat: support more kinds of method calls and operators.
Add tests. Start parsing some simpler fixture code.

997f4191d8
2024-02-07 19:42:13 +00:00
Kevin Newton
aad3c36bdf [ruby/prism] Support for Ruby 2.7
1a15b70a8e
2024-02-07 16:54:34 +00:00
Stan Lo
5f4245e74b [ruby/irb] Polish tracer integration and tests
(https://github.com/ruby/irb/pull/864)

* Remove useless ivar

* Simplify tracer test setup

* Treat tracer like a normal development dependency

* Only require ext/tracer when value is truthy

* Make tracer integration skip IRB traces

a97a4129a7
2024-02-07 14:59:10 +00:00
Hiroshi SHIBATA
d95d3484a9
omit tests related legacy provider
It failed with recent update of FreeBSD

20240207T023002Z.fail.html.gz
2024-02-07 16:06:01 +09:00
Kim Emmanuel
8bd83bb133 [rubygems/rubygems] fix flaky tests
0e87ae032d
2024-02-07 05:46:50 +00:00
Kim Emmanuel
aaef443a59 [rubygems/rubygems] release requirement may load prerelease when sole option
7990771939
2024-02-07 05:46:49 +00:00
Kim Emmanuel
5ddf4f5c95 [rubygems/rubygems] fix Gem::Dependency#to_spec returning nil when prerelease is the only available version
a7dcc7214b
2024-02-07 05:46:49 +00:00
Kevin Newton
2dba441397 [ruby/prism] Even more ripper compat
47a602dc1c
2024-02-07 03:21:02 +00:00
NARUSE, Yui
64b6a018a3
Fix test session reuse but expire (#9824)
* OpenSSL 3.2.1 30 Jan 2024 is also broken

Import 4506461072 from ruby_3_3 branch
tentatively.
2024-02-07 10:59:59 +09:00
Noah Gibbs
e34505c631 [ruby/prism] More visitors and tests for RipperCompat
Part of issue #2354

cb28edae34
2024-02-07 01:49:54 +00:00
Kevin Newton
ae13f85322 Add test-all to prism 2024-02-06 20:38:41 -05:00
eileencodes
936c0ab5e8 [ruby/prism] Implement file parsing error handling
This PR implements proper file parsing error handling. Previously
`file_options` would call `pm_string_mapped_init` which would print an
error from `perror`. However this wouldn't raise a proper Ruby error so
it was just a string output. I've done the following:

- Raise an error from `rb_syserr_fail` with the filepath in
`file_options`.
- No longer return `Qnil` if `file_options` returns false (because now
it will raise)
- Update `file_options` to return `static void` instead of `static
bool`.
- Update `file_options` and `profile_file` to check the type so when
passing `nil` we see a `TypeError`.
- Delete `perror` from `pm_string_mapped_init`
- Update `FFI` backend to raise appropriate errors when calling
`pm_string_mapped_init`.
- Add tests for `dump_file`, `lex_file`, `parse_file`,
`parse_file_comments`, `parse_lex_file`, and `parse_file_success?`
when a file doesn't exist and for `nil`.
- Updates the `bin/parse` script to no longer raise it's own
`ArgumentError` now that we raise a proper error.

Fixes: ruby/prism#2207

b2f7494ff5
2024-02-06 20:49:33 +00:00
Nikita Vasilevsky
c3403322df [PRISM] Use block node location when building block iseq
Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-02-06 14:56:10 -05:00
Kevin Newton
f5b368df0c [ruby/prism] Better invalid token messages
8c9bed2a4d
2024-02-06 18:10:50 +00:00
Nuno Silva
300dee1fe8 [ruby/irb] Fix usage of tracer gem and add tests
(https://github.com/ruby/irb/pull/857)

The new tests are skipped when ruby below 3.1, as it was a default gem on it, and in a version we do not support.

This also move definition of `use_tracer` to module Context instead of monkey patch.

08834fbd5f
2024-02-06 16:46:50 +00:00
Yusuke Endoh
19f615521d Remove TestProcess#test_low_memory_startup
It is too flaky on many platforms. Nobody is willing to fix it. Let's
just stop it.
2024-02-04 05:02:49 +09:00
Kevin Newton
c42b1029d9 [ruby/prism] Change the location of an implicit begin to method
d08e140859
2024-02-05 20:40:24 +00:00
David Rodriguez
ca7a48110f [rubygems/rubygems] Revert "Simplify how extensions are built"
This reverts commit 0b8faf1e39.

7528e0f1ce
2024-02-05 18:17:24 +00:00
Peter Zhu
948c618bda [PRISM] Fix encoding of interpolated strings
Fixes ruby/prism#2313.
2024-02-05 11:55:44 -05:00
Kevin Newton
0b5be2f9e9 Sync to latest prism 2024-02-05 11:07:07 -05:00
Jenny Shen
b35cdb4758 [PRISM] Implement opt_aset_with
Part of ruby/prism#2231

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2024-02-05 10:27:58 -05:00
NARUSE, Yui
bc79229be9 Show OpenSSL version in the error message of assert_equal 2024-02-03 19:39:17 +09:00
Nobuyoshi Nakada
124be0aaaa [ruby/irb] Consume the warning for non-existent history path
Fix https://github.com/ruby/irb/pull/852#issuecomment-1925170358

9a7e060e57
2024-02-03 06:54:35 +00:00
Alan Wu
90ae8eaeca [PRISM] Fix numbered parameters stealing local names
Previously, the local index of numbered parameters were assigned to
names of regular locals, making it hard to read both of them. Use proper
`_[1-9]` numbered parameters. This fixes `test_shapes.rb`.

Also, properly mark the iseq as having lead parameters.
2024-02-02 18:50:41 -05:00
Ignacio Chiazzo Cardarello
aa780a678e [ruby/irb] Add a warning for when the history path doesn't exist
(https://github.com/ruby/irb/pull/852)

* Add a warning for when the history path doesn't exist

* warn when the directory does not exist

* added test for when the history_file does not exist

* Update lib/irb/history.rb

---------

9e6fa67212

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-02-02 21:58:22 +00:00
Mike Dalessio
31e4300ea7 [rubygems/rubygems] feat: Gem::Specification#initialize_copy deep-copies requirements
to avoid accidentally mutating the original's state when doing:

```ruby
spec2 = spec.dup
spec2.required_rubygems_version.concat([">= 3.3.22"])
```

see https://github.com/rake-compiler/rake-compiler/pull/236 for a
real-world use case that would be made simpler with this behavior.

c1d52389f0
2024-02-02 21:38:04 +00:00
Mike Dalessio
66a6f2b15a [rubygems/rubygems] feat: Gem::Requirement#initialize_copy deep-copies @requirements
to avoid accidentally mutating the original's state when doing:

```ruby
req2 = req.dup
req2.concat([">= 3.3.22"])
```

see https://github.com/rake-compiler/rake-compiler/pull/236 for a
real-world use case that would be made simpler with this behavior.

8e0c03144e
2024-02-02 21:38:04 +00:00
Kevin Newton
7695ab3bce [ruby/prism] Fix up multibyte escapes
836a35f4af
2024-02-02 20:09:01 +00:00
Kevin Newton
520987c6d7 [ruby/prism] Turn off LibrarySymbolsTest on powerpc64le
6e432f3de5
2024-02-02 19:43:14 +00:00
Vitaliy Serov
93fdf66bc5 [rubygems/rubygems] Adapt failing tests to new output
cf549e71aa
2024-02-02 19:26:58 +00:00
Peter Zhu
31378dc096 Add memory leak test for Regexp timeout
[Bug #20228]
2024-02-02 10:39:42 -05:00
Nobuyoshi Nakada
ccffc6ee09
Add an assertion that %x literals call ` `` method 2024-02-02 14:26:20 +09:00
Alan Wu
8d33be9833
[PRISM] Respect string encoding override in array literals
Fixes `TestZlibGzipReader#test_gets2`,
`Psych_Unit_Tests#test_spec_explicit_families`, and many failures in
`test_unicode_normalize.rb`.
2024-02-01 22:11:32 +00:00
Alan Wu
770b5499a5 [ruby/prism] Amend assert in pm_utf_8_codepoint(), n=0 is fine
This assert used to trip in the included test:
```
./miniruby --parser=prism -e ' "%W"\u" '
```

8c0f84db4f
2024-02-01 22:04:46 +00:00
Jenny Shen
4fbdbde088 [PRISM] dedup hash string keys
Fixes ruby/prism#2321

Co-authored-by:  Adrianna Chang <adrianna.chang@shopify.com>
Co-authored-by:  Peter Zhu <peter@peterzhu.ca>
2024-02-01 15:52:33 -05:00
Kevin Newton
d3ba14a31d [PRISM] Do not shell out in prism tests 2024-02-01 14:13:22 -05:00
Stan Lo
ef427123ad [ruby/irb] Add rubocop with a few basic styling rules
(https://github.com/ruby/irb/pull/849)

* Use rubocop to enforce a few styling rules

* Add a CI job for linting

4f60cd88bb
2024-02-01 17:46:02 +00:00
Kevin Newton
494778c663 [ruby/prism] Remove locals_body_index
We're not using this anymore, and it doesn't make a lot of sense
outside the context of a compiler anyway, and in anyway it's wrong
when you have local variables written in default values.

5edbd9c25b
2024-02-01 16:48:55 +00:00
Haldun Bayhantopcu
67c5690a6d [ruby/prism] Check literals for receiver
56441b08e7
2024-02-01 16:48:09 +00:00