Commit graph

18546 commits

Author SHA1 Message Date
Kevin Newton
5f9f2fd72e [ruby/yarp] Add implicit nodes for ommitted hash values
22130b3491
2023-09-15 15:41:02 +00:00
Kevin Newton
b5084877c0 [ruby/yarp] Disallow numbered parameters in multiple scopes
5fd4d3b89a
2023-09-15 15:14:37 +00:00
Kevin Newton
a4b4ebc7c1 [ruby/yarp] Error when numbered parameters are written
65b536ba12
2023-09-15 15:14:36 +00:00
Kevin Newton
6031ab18c7 [ruby/yarp] Support parsing numbered parameters
ffc8f35e56
2023-09-15 15:14:34 +00:00
Kevin Newton
1badb09f61 [ruby/yarp] Properly handle missing method names
4a30c69051
2023-09-15 15:14:19 +00:00
Nobuyoshi Nakada
89802078f9
[Bug #19882] Reject tokens invalid as symbols 2023-09-15 17:27:36 +09:00
KJ Tsanaktsidis
0117a6d389
Fix Thread#native_thread_id being cached across fork (#8418)
The native thread ID can and does change on some operating systems (e.g.
Linux) after forking, so it needs to be re-queried.

[Bug #19873]
2023-09-15 10:33:32 +09:00
Kevin Newton
0d33bc0cde [ruby/yarp] Simplify multi-target parsing
This simplifies how we handle multi-targets, and also fixes a bug we
had where for loops were always getting multi-targets, even when there
was only a single target.

31eb8b7ad5
2023-09-14 19:16:39 +00:00
Kevin Newton
0a8f3670d1 [ruby/yarp] Introduce MatchWriteNode
This rarely used node holds information about the local variables
that need to get written in the case a regular expression is used on
the left-hand side of a =~ operator and it has named capture groups.

Note that we already "handled" these nodes by adding locals to the
AST, but we didn't actually expose this information, making it
difficult to compile.

The general idea behind this node is that it maintains the ability
for consumers to find all of the call nodes in the tree easily so
it's not flattening down. However, it should be okay because you
hopefully don't need any information in the call node to determine
what to compile because the locals list is on the top level.

e136e7f9a8
2023-09-14 19:10:58 +00:00
Kevin Newton
9d2549ac31 [ruby/yarp] Write names should not underflow size_t
If the read_name is invalid, we shouldn't try to set a write name.

06881c8ca7
2023-09-14 19:10:47 +00:00
Kevin Newton
63d1e05665 [ruby/yarp] Handle errors when operator writes on a call with a block
93bec2c173
2023-09-14 18:32:16 +00:00
Kevin Newton
fb1328e467 [ruby/yarp] Fix multi target parentheses locations
7f71527522
2023-09-14 18:31:55 +00:00
Kevin Newton
826bebb7d8 [ruby/yarp] Reject invalid call-operator-write
d3a852dac2
2023-09-14 18:30:11 +00:00
Kevin Newton
581bda0cba [ruby/yarp] Add a frozen string flag
09248a1f9e
2023-09-14 18:28:45 +00:00
Nobuyoshi Nakada
9cb33aad55
[Bug #19877] Fix flip-flop in block 2023-09-15 01:09:07 +09:00
Nobuyoshi Nakada
864bb8680c
[Bug #19877] Named captures should take place from regexps in block 2023-09-15 01:09:06 +09:00
Nobuyoshi Nakada
e8896a31d4
[Bug #19877] Literals cannot have singleton methods even in blocks 2023-09-15 01:09:06 +09:00
Kevin Newton
1b6d2b9184 [ruby/yarp] Fix up unary minus precedence
6be28eeed0
2023-09-14 13:58:33 +00:00
Kevin Newton
174aa53656 [ruby/yarp] Handle concat character literal and string
fb141b8d07
2023-09-14 13:58:13 +00:00
Kevin Newton
57745450dd [ruby/yarp] Extract out heredoc parsing into parse_strings
c5a1094988
2023-09-14 13:58:12 +00:00
Kevin Newton
9a1c5a1268 [ruby/yarp] Handle invalid operator write on fcall
22c800eab1
2023-09-14 13:39:06 +00:00
Samuel Williams
a095740fed
Fix io_buffer_get_string default length computation. (#8427)
* Fix `io_buffer_get_string` default length computation.

When an offset bigger than the size is given, the resulting length will be
computed incorrectly. Raise an argument error in this case.

* Validate all arguments.
2023-09-14 20:37:43 +12:00
Nobuyoshi Nakada
998ae7c3f3
[Bug #19868] Deprecate Process::Status#& and Process::Status#>> 2023-09-14 15:26:25 +09:00
Nobuyoshi Nakada
b6de0a6c69
[Bug #19868] Suggest other Process::Status method for & and >>
`Process::Status#&` and `Process::Status#>>` are provided only for
the backward compatibility with older Ruby than 1.8 where `$?` was
a `Fixnum`, and the knowledge about internals of system dependent
macros is necessary to use them.  Modern programs and libraries
should not need these methods.
2023-09-14 14:57:57 +09:00
Nobuyoshi Nakada
efe5e6e8d0
Negative value to Process::Status method for compatibility 2023-09-14 14:38:14 +09:00
Kevin Newton
90838a9490 [ruby/yarp] Fix associativity for a couple of operators
820774976d
2023-09-13 13:50:13 +00:00
Kevin Newton
f9898b9eca [ruby/yarp] Better handle invalid gvar writes
eaaebc17c8
2023-09-13 13:40:46 +00:00
Nobuyoshi Nakada
ea75a682a9 [ruby/yarp] Mark empty flags as well as locations and blocks
b74ce35379
2023-09-13 12:48:39 +00:00
Yusuke Endoh
411572661a math.c: Fix Math.log against huge bignum [Bug #19878] 2023-09-13 21:40:05 +09:00
Hiroshi SHIBATA
c75d54a36c
Fixup 1851824b1c 2023-09-13 16:23:18 +09:00
Hiroshi SHIBATA
1851824b1c [flori/json] alias_method is private on Ruby 2.3 and 2.4
573ef94bc5
2023-09-13 16:01:19 +09:00
Nobuyoshi Nakada
234722ed9f [Bug #19872] Refine TestRequireLib
Always test only the scripts just under “lib", and just under
child directories which has not the same name script in the upper
level; instead of random sampling from whole libraries.
2023-09-13 10:43:10 +09:00
Nobuyoshi Nakada
435b243978
Suppress an unused variable warning 2023-09-13 10:24:55 +09:00
Kevin Newton
c421f08f6b [ruby/yarp] Handle parsing local variable singleton method definition
943204d56f
2023-09-13 00:55:04 +00:00
Nobuyoshi Nakada
6e64d43704 [Bug #19862] Skip compiled result of never reachable expression 2023-09-13 08:30:37 +09:00
Nobuyoshi Nakada
19346c2336
[Bug #19754] Make IO::Buffer#get_string check offset range (#8016) 2023-09-13 09:45:26 +12:00
Kevin Newton
a98209b8a7 [ruby/yarp] Split AliasNode
Into AliasGlobalVariableNode and AliasMethodNode. These have different
enough semantics that we feel comfortable splitting them up.

c1f3e6d344
2023-09-12 15:44:25 +00:00
Alan Wu
39ee3e22bd Make Kernel#lambda raise when given non-literal block
Previously, Kernel#lambda returned a non-lambda proc when given a
non-literal block and issued a warning under the `:deprecated` category.
With this change, Kernel#lambda will always return a lambda proc, if it
returns without raising.

Due to interactions with block passing optimizations, we previously had
two separate code paths for detecting whether Kernel#lambda got a
literal block. This change allows us to remove one path, the hack done
with rb_control_frame_t::block_code introduced in 85a337f for supporting
situations where Kernel#lambda returned a non-lambda proc.

[Feature #19777]

Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-09-12 11:25:07 -04:00
Nobuyoshi Nakada
385033ba0f
Ensure signaled processes at opening FIFO terminated 2023-09-12 23:28:48 +09:00
Jemma Issroff
39336c1ab8 [ruby/yarp] Heredocs can create Interpolated(X)StringNodes or
(X)StringNodes
(https://github.com/ruby/yarp/pull/1427)

Prior to this commit, heredocs were automatically InterpolatedNodes
regardless of whether there was actually interpolation. With this
commit, heredocs are only interpolate if there is actually
interpolation

e9f436128b
2023-09-12 13:39:24 +00:00
Benoit Daloze
fe3eff08ee [ruby/yarp] Move the post required parameters after the rest parameter
* See https://github.com/ruby/yarp/issues/1436

6f4e9ff940
2023-09-12 12:11:40 +00:00
Kevin Newton
8953fc774c [ruby/yarp] Provide a flag for the integer base
45dd046b83
2023-09-11 21:49:51 +00:00
Kevin Newton
b7ffa74d58 [ruby/yarp] Introduce MatchLastLineNode and InterpolatedMatchLastLineNode
These are replacements for regular expressions when they are used
alone as the predicate of a conditional. That's because they are
significantly different from a regular expression because they are
not evaluated for truthyness, but instead evaluated as a match
against the last line read by an IO object.

0f1c7780e8
2023-09-11 21:42:03 +00:00
Kevin Newton
14a83e0879 [ruby/yarp] Update pretty_print to use inspect
c2b9b780c7
2023-09-11 21:32:15 +00:00
negi0109
8bb61077ad [rubygems/rubygems] Fixed false positive SymlinkError in symbolic link directory
58173ff2ea
2023-09-11 21:06:21 +00:00
Kevin Newton
719f834466 [ruby/yarp] Mark flags as private
The flags integer is an implementation detail. We want people to
use the query methods to access the individual fields so we are
freed from having to maintain a specific order. As such, this
commit changes the Ruby API to mark all flags fields as private
attr_readers.

The only one that has a clear use case is returning the set of
options given to regular expressions, to mirror the Regexp#options
API. So, to support this use case, this commit introduces
RegularExpressionNode#options and InterpolatedRegularExpressionNode#options.
These APIs provide back the same integer so that they can be used
interchangeably.

4e6d5dd99f
2023-09-11 16:18:32 +00:00
Tim Morgan
05a853c2f2 [ruby/yarp] Update fixtures
884f2ca8e4
2023-09-11 15:25:06 +00:00
Tim Morgan
689dffc857 [ruby/yarp] Add failing test for Regexp flags
16fe179c5f
2023-09-11 15:25:05 +00:00
Kevin Newton
5d73c0f3df [ruby/yarp] Move parse result mutations into their own files
3be8272fa2
2023-09-08 19:38:17 +00:00
Jemma Issroff
7fc4db35ee
[YARP] Implement compilation for RationalNodes, fix other num types (#8404) 2023-09-08 15:33:51 -04:00