Commit graph

18546 commits

Author SHA1 Message Date
Hiroya Fujinami
3e64cf60b5
Fix [Bug #19632]: Disable external iterator for frozen enumerator (#7791)
* Fix [Bug #19632]: Disable external iterator for frozen enumerator

Currently, methods to manipulate an external iterator like `#next`
and `#feed` can be called even if a receiver of an enumerator is
frozen. However, these methods change the state of an external
iterator in an enumerator. Therefore, it seems a BUG to me, and
these methods should raise FrozenError if the receiver is frozen.

This fixed the following methods to raise FrozenError if the receiver is
frozen.

- `Enumerator#next`
- `Enumerator#next_values`
- `Enumerator#peek`
- `Enumerator#peek_values`
- `Enumerator#feed`
- `Enumerator#rewind`

* Fix a typo in the document

Thanks @Maumagnaguagno.
2023-10-25 16:32:25 +09:00
Aaron Patterson
d8cb827f39 Remove SHAPE_MAX_NUM_IVS
There is no longer a limit on the number of IVs you can store.
SHAPE_MAX_NUM_IVS was used to work around the IV10K problem (the well
known problem where setting 10k instance variables in a row would be too
slow).  The redblack tree works well at any shape depth, even depths
greater than 80, and solves the IV10K problem.
2023-10-24 14:23:17 -07:00
Aaron Patterson
a3f66e09f6 geniv objects can become too complex 2023-10-24 10:52:06 -07:00
Jemma Issroff
39207b496e [PRISM] Implement compilation for PreExecutionNodes 2023-10-23 13:22:55 -07:00
Jemma Issroff
7c4e3ca27b [PRISM] Fix AssocSplat node
This commit emits the correct instructions for hashes which have
both AssocSplat and Assoc nodes contained within them
2023-10-23 13:15:52 -07:00
dearblue
062d6050b0 [rubygems/rubygems] Ignore non-tar format .gem files during search
Previously, `rake install` or `rake update` would fail if there was a non-tar format `.gem` file in the current working directory.

f562788f1d
2023-10-23 19:52:22 +00:00
Jemma Issroff
60196b4780 [PRISM] Fix __LINE__ to be 1-indexed by default 2023-10-23 13:59:48 -03:00
Jemma Issroff
f9e122b3d6 [PRISM] Add several tests 2023-10-23 13:59:48 -03:00
Jemma Issroff
62c674f98c [PRISM] Fix compilation for IfNode, UnlessNode
This properly implements the branch condition for FlipFlopNodes on
If / UnlessNodes, and also fixes the bug in UnlessNodes
2023-10-23 12:37:50 -03:00
Jemma Issroff
296da1a2b8
[PRISM] Add tests for BlockNode, BlockLocalVariableNode, BlockParamet… (#8725)
[PRISM] Add tests for BlockNode, BlockLocalVariableNode, BlockParametersNode
2023-10-23 12:30:38 -03:00
Martin Emde
499e66d05c [rubygems/rubygems] Gem::NameTuple equality ignores Gem::Platform/string platform variation
49aaa46708
2023-10-21 20:35:34 +00:00
Stan Lo
745879b5ed [ruby/irb] Minor refactors around irb.rb
(https://github.com/ruby/irb/pull/736)

* Remove dead method

* Simplify IRB.version

* Move private Irb methods together

* Centralise @CONF initialization/assignment in init.rb

* Move attr_* calls above initialize method

cf23be4395
2023-10-21 18:06:00 +00:00
Charles Oliver Nutter
55d954721e
Raise TypeError for bad IO::Buffer.map argument (#8728)
* Raise TypeError when IO::Buffer.map argument is neither IO nor implements #fileno

* Use UNREACHABLE_CODE

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

* Use macro for undef check

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

---------

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-10-21 17:30:40 +13:00
Charles Oliver Nutter
0e62802c3b
Extract IO::Buffer.for string locking test (#8729)
String locking with locktmp is not really part of the public API,
and the test relies in a side effect of using it to protect the
buffer. On other implementations without locktmp this does not
fail. Separate into its own test so it can be excluded from public
API expectations.
2023-10-21 02:00:18 +00:00
Takashi Kokubun
8a88172fd4
YJIT: Skip printing stats at exit if --yjit-disable (#8727) 2023-10-20 13:12:38 -07:00
Jemma Issroff
01787d53bf [PRISM] Setup encodings in prism compiler 2023-10-20 16:29:06 -03:00
Alan Wu
fab7018346
YJIT: On test_bug_19316, only check the result
Because the `&` call checks for interrupts, the test was accidentally
timing dependent. Stop checking for exits.

[Bug #19921]

Reported-by: Vít Ondruch <vondruch@redhat.com>
Reported-by: Mamoru Tasaka <mtasaka@fedoraproject.org>
2023-10-20 17:00:52 +00:00
Jemma Issroff
1c48d15d6b Add tests for all implemented nodes, leave ones that need fixing commented out 2023-10-20 11:49:53 -03:00
Jemma Issroff
40624d4921 Added TODOs on all implemented nodes, matched ordering 2023-10-20 11:49:53 -03:00
Jemma Issroff
a426a230de [PRISM] Fixed StringConcatNode, uncommented tests 2023-10-20 11:49:53 -03:00
Nobuyoshi Nakada
9d1940ba3c [Bug #19966] [PRISM] Fix singleton method definition 2023-10-20 15:16:34 +09:00
Nobuyoshi Nakada
84dfa0fa5e [PRISM] Enclose in the test class 2023-10-20 15:16:34 +09:00
Alan Wu
9194f489c9 YJIT: Make test_yjit.rb faster with --yjit-stats=quiet
The for-human stats summaries are not relevant for the children
`test_yjit.rb` spawns. Avoid compiling and running the printing code.
On a -O0 dev build this halves the time for `test_yjit.rb` on my machine.
2023-10-19 15:14:20 -04:00
Alan Wu
9047fe5ea4 YJIT: Print exit reasons on failure in test_yjit.rb
For <https://bugs.ruby-lang.org/issues/19921>, I suspect the test is
failing due to a timing related interrupt, which on paper could
happen with slow-enough GC runs.

In any case, it's helpful for debugging to have more information when
tests fail.

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-10-19 15:14:20 -04:00
Takashi Kokubun
6beb09c2c9
YJIT: Add RubyVM::YJIT.enable (#8705) 2023-10-19 10:54:35 -07:00
Yusuke Endoh
ccd2f8c1ca Skip some timeout tests on s390x
They are too unstable on the machine.

```
  1) Failure:
TestRegexp#test_timeout_shorter_than_global [/home/chkbuild/chkbuild/tmp/build/20231018T230003Z/ruby/test/ruby/test_regexp.rb:1788]:
Expected |0.2 - 0.962938869| (0.7629388690000001) to be <= 0.15000000000000002.
```
20231018T230003Z.fail.html.gz

```
  1) Failure:
TestRegexp#test_timeout_longer_than_global [/home/chkbuild/chkbuild/tmp/build/20231017T140006Z/ruby/test/ruby/test_regexp.rb:1788]:
Expected |0.5 - 1.040696078| (0.5406960780000001) to be <= 0.375.
```
20231017T140006Z.fail.html.gz
2023-10-18 10:19:06 +09:00
Aaron Patterson
10272b2790 Use assert_separately to avoid defining foo
When we eval the iseqs generated by prism, they can have side effects
like defining methods.  In this case, we were defining the method "foo",
but other tests were expecting that the foo method would _not_ be
defined.
2023-10-18 17:16:11 -07:00
Jemma Issroff
252b0fc715 Temporarily removed location code on scope nodes 2023-10-18 17:16:11 -07:00
Jemma Issroff
ba3a99acaf Remove pm_compile_context_t, move the context onto ScopeNode
We changed ScopeNodes to point to their parent (previous) ScopeNodes.
Accordingly, we can remove pm_compile_context_t, and store all
necessary context in ScopeNodes, allowing us to access locals from
outer scopes.
2023-10-18 17:16:11 -07:00
Katherine Oelsner
0ac6fb225d Add test for many ivars
Co-authored-by: John Hawthorn <john@hawthorn.email>
2023-10-18 15:01:13 -07:00
Jeremy Evans
de07645019 [ruby/drb] Support :SSL{Min,Max}Version config options
These are necessary to get the tests passing with LibreSSL 3.8.1+,
which dropped support for TLSv1.0 and TLSv1.1 for security reasons.

This updates the tests to use TLSv1.2 on OpenBSD.  This is only
strictly necessary on OpenBSD 7.4+, but it will work fine in previous
versions as well.

32707b2db5
2023-10-18 21:13:21 +00:00
Kevin Newton
8210cc4218 [ruby/prism] Fix lex compat when dedent should be 0
41c0e0e06e
2023-10-18 16:09:16 +00:00
Kevin Newton
5d0604366e [ruby/prism] Add * and & to methods with ...
e8114a786a
2023-10-18 16:08:31 +00:00
Kevin Newton
9c973f9555 [ruby/prism] Use the unescaped regexp to scan for capture groups
555551e8f2
2023-10-18 14:23:46 +00:00
Kevin Newton
2a6f7cd925 [ruby/prism] Index{Operator,And,Or}WriteNode
Right now, our Call{Operator,And,Or}WriteNode nodes represent two
different concepts:

```ruby
foo.bar += 1
foo[bar] += 1
```

These two statements are different in what they can support. The
former can never have arguments (or an opening_loc or closing_loc).
The former can also never have a block. Also, the former is a
variable method name.

The latter is always going to be []/[]=, it can have any number of
arguments including blocks (`foo[&bar] ||= 1`), and will always
have an opening_loc and closing_loc.

Furthermore, these statements end of having to take different paths
through the various compilers because with the latter you have to
consider the arguments and the block, whereas the former can
perform some additional peephole optimizations since there are
fewer values on the stack.

For these reasons, I'm introducing Index{Operator,And,Or}WriteNode.
These nodes never have a read_name or write_name on them because
they are always []/[]=. They also support blocks, which the previous
write nodes didn't. As a benefit of introducing these nodes, I've
removed the opening_loc, closing_loc, and arguments from the older
write nodes because they will always be null.

For the serialized format, both of these nodes end up being
smaller, and for in-memory we're storing fewer things in general,
so we have savings all around.

I don't love that we are introducing another node that is a call
node since we generally want consumers to only have to handle a
single call, but these nodes are so specific that they would have
to be handled separately anyway since in fact call 2 methods.

70155db9cd
2023-10-18 14:23:26 +00:00
Kyle Stevens
ef3f9f1a68 [rubygems/rubygems] Allow uninstalling multiple versions of same gem
Currently, you can install multiple versions of the same gem just fine:

```
$ gem install simplecov:0.19.0 simplecov:0.22.0
Fetching simplecov-0.19.0.gem
Successfully installed simplecov-0.19.0
Parsing documentation for simplecov-0.19.0
Installing ri documentation for simplecov-0.19.0
Done installing documentation for simplecov after 0 seconds
Fetching simplecov-0.22.0.gem
Successfully installed simplecov-0.22.0
Parsing documentation for simplecov-0.22.0
Installing ri documentation for simplecov-0.22.0
Done installing documentation for simplecov after 0 seconds
2 gems installed
```

But to uninstall both of them, you need to run the equivalent uninstall
command twice:

```
~$ gem uninstall simplecov:0.19.0 simplecov:0.22.0
Successfully uninstalled simplecov-0.22.0
~$ gem uninstall simplecov:0.19.0 simplecov:0.22.0
Gem 'simplecov' is not installed
Successfully uninstalled simplecov-0.19.0
```

This resolves that problem by using the gem's full name (which includes
the version) when tracking which ones have already been uninstalled so
when it gets to the second version listed it doesn't think it was
already uninstalled.

d96101b753
2023-10-18 10:17:58 +00:00
Koichi Sasada
46b8846b5c Show backtraces when failed
If `assert_equal(backtrace_locations.size, profile_frames.size)` in
`TestProfileFrames#test_matches_backtrace_locations_main_thread`
failed, we do not have enough information about it like that:

```
    1) Failure:
  TestProfileFrames#test_matches_backtrace_locations_main_thread [/home/runner/work/ruby/ruby/src/test/-ext-/debug/test_profile_frames.rb:148]:
  <31> expected but was
  <30>.
```

This patch shows both `backtrace_locations` and `profile_frames`
if failed.
2023-10-18 18:10:24 +09:00
Peter Zhu
f546fe15d5 Loosen assertion for flaky weak references test 2023-10-18 11:01:43 +02:00
Takashi Kokubun
7a3a98e2be
YJIT: Use RbConfig.ruby instead of EnvUtil.rubybin (#8689)
Some people encounter an issue that test_yjit uses the installed Ruby
instead of the currently-running Ruby. It's fixed when they remove the
installed Ruby.

However, test_yjit should run the currently-running Ruby for testing
YJIT in subprocesses. EnvUtil is unfortunately used outside tests as
well, so for compatibility reasons, this commit only changes the
argument given to EnvUtil.invoke_ruby to always use RbConfig.ruby.

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2023-10-18 00:47:13 +00:00
eileencodes
5a3e8d2f18 [ruby/prism] Ensure last encoding flag wins
You can't encoding a string with more than one encoding so ensure that
the last one wins.

4182c988c9
2023-10-17 17:50:38 +00:00
Koichi Sasada
c9990c8d0f "+MN" in description
If `RUBY_MN_THREADS=1` is given, this patch shows `+MN` in
`RUBY_DESCRIPTION` like:

```
$ RUBY_MN_THREADS=1 ./miniruby  --yjit -v
ruby 3.3.0dev (2023-10-17T04:10:14Z master 908f8fffa2) +YJIT +MN [x86_64-linux]
```

Before this patch, a warning is displayed if `$VERBOSE` is given.
However it can make troubles with tests (with `$VERBOSE`), do not
show any warning with a MN threads configuration.
2023-10-17 17:43:52 +09:00
Kevin Newton
9bd99cc171 [ruby/prism] Fix up super with a blockarg
0ea19ed823
2023-10-17 00:42:31 +00:00
Kevin Newton
9f16f07cf1 [ruby/prism] Additionally handle encoding comments in vim mode
bf9bdb9d82
2023-10-16 15:40:19 -07:00
Kevin Newton
39dd3343d8 [ruby/prism] Parse all magic comments
2b3d59f424
2023-10-16 15:40:19 -07:00
Jeremy Evans
3dec5dc346 [ruby/net-http] Force TLS version to 1.2 when using LibreSSL
This comment previously specified TLS 1.2, but actually set the
version to TLS 1.0.  LibreSSL 3.8.1 (included in OpenBSD 7.4)
dropped support for TLS 1.0/1.1 for security reasons, which
broke this test.  Switch the test to use TLS 1.2 as documented
so it will continue to work on OpenBSD 7.4+.

97be4de53a
2023-10-16 20:23:50 +00:00
Jemma Issroff
10d88ec9c3
[PRISM] Compile AliasGlobalVariableNode (#8675) 2023-10-16 12:00:01 -07:00
Jemma Issroff
728286d0e8
[PRISM] Fix more bugs in the compiler (#8658)
* Fixed ConstantPathWriteNode
* FIxed FlipFlopNode
2023-10-16 06:31:32 -07:00
Adam Hess
6e88b72d7b
[PRISM] prevent underflow on popped splatarray (#8657)
prevent underflow on popped splatarray

This only emits the splat array node when not popped
2023-10-16 05:22:07 -07:00
Nobuyoshi Nakada
06a4011964 [ruby/irb] Suppress "Switch to inspect mode" messages
This message is displayed if STDIN is not a tty.  The parallel test is
the case.

e26e90e3fb
2023-10-16 12:09:05 +00:00
Ellen Marie Dash
45a5ea5a0a [rubygems/rubygems] Remove kludge that should be unnecessary.
f1d44ecb62
2023-10-16 13:51:08 +09:00