Граф коммитов

17467 Коммитов

Автор SHA1 Сообщение Дата
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
https://github.com/flori/json/commit/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
https://github.com/ruby/yarp/commit/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.

https://github.com/ruby/yarp/commit/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

https://github.com/ruby/yarp/commit/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

https://github.com/ruby/yarp/commit/6f4e9ff940
2023-09-12 12:11:40 +00:00
Kevin Newton 8953fc774c [ruby/yarp] Provide a flag for the integer base
https://github.com/ruby/yarp/commit/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.

https://github.com/ruby/yarp/commit/0f1c7780e8
2023-09-11 21:42:03 +00:00
Kevin Newton 14a83e0879 [ruby/yarp] Update pretty_print to use inspect
https://github.com/ruby/yarp/commit/c2b9b780c7
2023-09-11 21:32:15 +00:00
negi0109 8bb61077ad [rubygems/rubygems] Fixed false positive SymlinkError in symbolic link directory
https://github.com/rubygems/rubygems/commit/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.

https://github.com/ruby/yarp/commit/4e6d5dd99f
2023-09-11 16:18:32 +00:00
Tim Morgan 05a853c2f2 [ruby/yarp] Update fixtures
https://github.com/ruby/yarp/commit/884f2ca8e4
2023-09-11 15:25:06 +00:00
Tim Morgan 689dffc857 [ruby/yarp] Add failing test for Regexp flags
https://github.com/ruby/yarp/commit/16fe179c5f
2023-09-11 15:25:05 +00:00
Kevin Newton 5d73c0f3df [ruby/yarp] Move parse result mutations into their own files
https://github.com/ruby/yarp/commit/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
Vinicius Stock 6050b5a4e8 [ruby/yarp] Add ParseResult#attach_comments! to tie comments to their locations
https://github.com/ruby/yarp/commit/ddc699156f

Co-authored-by: Kevin Newton <kddnewton@users.noreply.github.com>
2023-09-08 18:10:26 +00:00
Matt Valentine-House 7f53da94fb Fix weak_references count test
This test creates a lot of Objects held in an array, and a set of weak
references to them using WeakMap. It then clears the array and frees it
and asserts that all the weak references to it are also gone.

This test is failing because one of the dummy objects in our weakmap is
ending up on the stack, and so is being marked, even though we thought
that we'd removed the only reference to it.

This behaviour has changed since this commit:

5b5ae3d9e0

which rewrites `Integer#times` from C into Ruby. This change is somehow
causing the last object we append to our array to consistently end up on
the stack during GC.

This commit fixes the specific weakmap test by using an enumerator and
each, instead of `Integer#times`, and thus avoids having our last object
created end up on the stack.
2023-09-08 17:45:00 +01:00
Jemma Issroff af5df9ee5e
[YARP] Implement compilation for Regex / InterpolatedRegex (#8396) 2023-09-08 12:09:30 -04:00
Jemma Issroff 8807b0dc96
[YARP] Implement compilation for InterpolatedXStringNode (#8395)
* [YARP] Implemented compilation for InterpolatedXStringNode

* Extract common function for interpolated nodes
2023-09-08 10:40:07 -04:00
Kevin Newton c7d61181d0 [ruby/yarp] Flatten multitarget into multiwrite
https://github.com/ruby/yarp/commit/1021dac372
2023-09-08 13:40:28 +00:00
Kevin Newton f39b576e76 [ruby/yarp] Multi target nodes
https://github.com/ruby/yarp/commit/fa53fe88e4
2023-09-08 13:40:28 +00:00
Takashi Kokubun 5b5ae3d9e0
Rewrite Integer#times in Ruby (#8388) 2023-09-07 10:57:52 -07:00
Mike Dalessio 4efcaf956e [ruby/yarp] Extract error messages into diagnostic.c and use canonical message IDs
The parser now passes around `yp_diagnostic_id_t` for diagnostic
messages instead of character strings, and we rely on the function
`diagnostic_message()` to resolve that to a string.

In addition, many messages were edited so that the parser expresses
coordinate ideas in similar form [1] using consistent voice and
typographic conventions.

Closes https://github.com/ruby/yarp/pull/1379, and makes progress on #941.

  [1] Strunk & White rule 19

https://github.com/ruby/yarp/commit/0b6dd85bf1
2023-09-07 16:36:56 +00:00
Jemma Issroff 7adc38b895
[YARP] Miscellaneous small bug fixes (#8387) 2023-09-07 10:59:51 -04:00
Kevin Newton 194584f202 [ruby/yarp] Introduce owned constants
Before this commit, constants in the constant pool were assumed to
be slices of the source string. This works in _almost_ all cases.

There are times, however, when a string needs to be synthesized.
This can occur when passing in locals that need to be scoped through
eval, or when generating method names like `foo=`.

After this commit, there is a single bit `owned` boolean on
constants in the pool that indicates whether or not it is a slice
of the source string. If it is not, it is assumed to be allocated
memory that should be freed by the constant pool when the constant
pool is freed.

When serializing, the most significant bit in the location of the
contents of the constant indicates whether or not it is owned.
When it is, instead of 4 bytes for the source offset and 4 bytes
for the length it is instead 4 bytes for the buffer offset and 4
bytes the length. The contents of the owned constants are embedded
into the buffer after the constant pool itself.

https://github.com/ruby/yarp/commit/461c047365
2023-09-07 14:01:21 +00:00
Kevin Newton 14970cfc8d [ruby/yarp] Constants and def nodes
https://github.com/ruby/yarp/commit/6b2421ce1b
2023-09-07 12:42:02 +00:00
Kevin Newton 9343ef2504 [ruby/yarp] Constants on rest parameter nodes
https://github.com/ruby/yarp/commit/a6fdb8aae9
2023-09-07 12:42:02 +00:00
Kevin Newton 3f78eec44a [ruby/yarp] Constants on keyword rest parameters
https://github.com/ruby/yarp/commit/5e1a8fbc54
2023-09-07 12:42:01 +00:00
Kevin Newton 9e21b33ece [ruby/yarp] Constants on keyword parameters
https://github.com/ruby/yarp/commit/d2d4f25a23
2023-09-07 12:42:00 +00:00
Kevin Newton e2a0f25888 [ruby/yarp] Remove name constant from classes/modules
https://github.com/ruby/yarp/commit/26105f0b58
2023-09-07 12:41:45 +00:00
Nobuyoshi Nakada bd046764e3
[Bug #19549] Check for variables to be interpolated 2023-09-07 13:41:13 +09:00
Samuel Williams 05aaff2191
Reduce number of iterations in `TestFiberScheduler#test_autoload`. (#8391)
`ppc64le` appears to be struggling with this test due to timeout. Let's see
if reducing the number of iterations can help improve the test performance.
2023-09-07 13:53:51 +12:00
Vinicius Stock acd626a583 [ruby/yarp] Consider source encoding for `slice`
https://github.com/ruby/yarp/commit/8f59fc27cd

Co-authored-by: Kevin Newton <kddnewton@users.noreply.github.com>
2023-09-06 19:50:21 +00:00
Andy Waite fdf7aad902 [ruby/yarp] Fix `Location#end_column`
https://github.com/ruby/yarp/commit/00e4711026
2023-09-06 18:37:41 +00:00
Peter Zhu 12102d101a Fix crash in WeakMap during compaction
WeakMap can crash during compaction because the st_insert could allocate
memory.
2023-09-06 14:20:23 -04:00
Kevin Newton 746eede412 [ruby/yarp] Constant on block parameter node
https://github.com/ruby/yarp/commit/2cd9a67150
2023-09-06 18:18:10 +00:00
Peter Zhu 08929b344d Try to fix flaky test_warmup_frees_pages
This test sometimes fails with:

```
  1) Failure:
TestProcess#test_warmup_frees_pages [test/ruby/test_process.rb:2750]:
<202> expected but was
<203>.
```
2023-09-06 13:31:50 -04:00
Kevin Newton dee383b262 [ruby/yarp] Constants on classes and modules
(https://github.com/ruby/yarp/pull/1409)

https://github.com/ruby/yarp/commit/0a11ec579f
2023-09-06 16:19:43 +00:00
Kevin Newton a52ac350cc [ruby/yarp] Fix assert_raises in YARP
https://github.com/ruby/yarp/commit/8f8f3530aa
2023-09-06 14:30:55 +00:00
Kevin Newton 5537169ef0 [ruby/yarp] Temporarily add name_constant to replace name on ClassNode/ModuleNode
https://github.com/ruby/yarp/commit/8f87686e9c
2023-09-06 14:20:13 +00:00
Kevin Newton dae6a0a295 [ruby/yarp] Introduce YARP::Pattern
https://github.com/ruby/yarp/commit/2a12e9637b
2023-09-06 14:19:58 +00:00
Kevin Newton 4c9a036606 [ruby/yarp] Add constants and constants
https://github.com/ruby/yarp/commit/d7eaa89bc3
2023-09-06 13:00:23 +00:00
Kazuki Yamaguchi 5ba480e4ea
Use the test-unit-ruby-core gem for Test::Unit::CoreAssertions
test/lib/core_assertions.rb and its dependencies are now packaged in
the gem test-unit-ruby-core. Let's use it instead.
2023-09-06 19:51:53 +09:00
Kazuki Yamaguchi 3fd90c0158 [ruby/openssl] test/openssl/test_pkey_ec.rb: refactor tests for EC.builtin_curves
Check that OpenSSL::PKey::EC.builtin_curves returns an array in the
expected format.

Similarly to OpenSSL::Cipher.ciphers, OpenSSL::PKey::EC.builtin_curves
returns a list of known named curves rather than actually usable ones.

https://github.com/ruby/openssl/issues/671 found that the list may
include unapproved (and thus unusable) curves when the FIPS module is
loaded.

https://github.com/ruby/openssl/commit/c53cbabe00
2023-09-06 19:31:11 +09:00
Kazuki Yamaguchi 1d4a43e7b0 [ruby/openssl] test/openssl/test_ossl.rb: relax assertion for error messages
The test case test_error_data utilizes the error message generated by
X509V3_EXT_nconf_nid(). The next commit will use X509V3_EXT_nconf(),
which generates a slightly different error message. Let's adapt the
check to it.

https://github.com/ruby/openssl/commit/9cdfa3a4d1
2023-09-06 19:30:55 +09:00
Michael Richardson 91e5f51607 [ruby/openssl] x509ext: let X509::ExtensionFactory#create_ext take a dotted OID string
instead of looking of NIDs and then using X509V3_EXT_nconf_nid,
instead just pass strings to X509V3_EXT_nconf, which has all the logic for
processing dealing with generic extensions
also process the oid through ln2nid() to retain compatibility.

[rhe: tweaked commit message and added a test case]

https://github.com/ruby/openssl/commit/9f15741331
2023-09-06 19:30:32 +09:00
Kazuki Yamaguchi 98d8f6128e [ruby/openssl] x509ext: test OpenSSL::X509::ExtensionFactory#create_ext with ln
OpenSSL::X509::ExtensionFactory#create_ext and #create_extensions
accepts both sn (short names) and ln (long names) for registered OIDs.

This is different from the behavior of the openssl command-line utility
which accepts only sn in openssl.cnf keys.

Add a test case to check this.

https://github.com/ruby/openssl/commit/91ae46c8d7
2023-09-06 19:28:47 +09:00
Mau Magnaguagno 60a6de81a8 [ruby/openssl] Prefer String#unpack1
(https://github.com/ruby/openssl/pull/586)

String#unpack1 avoids the intermediate array created by String#unpack
for single elements, while also making a call to Array#first/[0]
unnecessary.

https://github.com/ruby/openssl/commit/8eb0715a42
2023-09-06 19:24:53 +09:00
Kazuki Yamaguchi 912f1cda0d [ruby/openssl] Remove OSSL_DEBUG compile-time option
Remove the OSSL_DEBUG flag and OpenSSL.mem_check_start which is only
compiled when the flag is given. They are meant purely for development
of Ruby/OpenSSL.

OpenSSL.mem_check_start helped us find memory leak bugs in past, but
it is no longer working with the recent OpenSSL versions. Let's just
remove it now.

https://github.com/ruby/openssl/commit/8c7a6a17e2
2023-09-06 19:20:57 +09:00
Jemma Issroff ae96232161
[YARP] Fix warning on compiling constant test (#8377) 2023-09-05 17:29:32 -04:00
Kevin Newton 767f984017 [ruby/yarp] Flatten CallAndWriteNode, CallOrWriteNode, and CallOperatorWriteNode
https://github.com/ruby/yarp/commit/8f26ffa0b2
2023-09-05 19:13:30 +00:00
Kevin Newton c384ef0799 [ruby/yarp] Introduce a BlockLocalVariableNode
This is a tradeoff that I think is worth it. Right now we have a
location list that tracks the location of each of the block locals.
Instead, I'd like to make that a node list that has a proper node
in each spot in the list. In doing so, we eliminate the need to have
a location list at all, making it simpler on all of the various
consumers as we have one fewer field type. There should be minimal
memory implications here since this syntax is exceedingly rare.

https://github.com/ruby/yarp/commit/04d329ddf0
2023-09-05 18:41:51 +00:00
Yusuke Endoh 5b146eb5a1 Prevent "ambiguous first argument" warnings
```
/home/chkbuild/chkbuild/tmp/build/20230905T063003Z/ruby/test/yarp/compiler_test.rb:16: warning: ambiguous first argument; put parentheses or a space even after `+' operator
/home/chkbuild/chkbuild/tmp/build/20230905T063003Z/ruby/test/yarp/compiler_test.rb:17: warning: ambiguous first argument; put parentheses or a space even after `-' operator
/home/chkbuild/chkbuild/tmp/build/20230905T063003Z/ruby/test/yarp/compiler_test.rb:28: warning: ambiguous first argument; put parentheses or a space even after `+' operator
/home/chkbuild/chkbuild/tmp/build/20230905T063003Z/ruby/test/yarp/compiler_test.rb:29: warning: ambiguous first argument; put parentheses or a space even after `-' operator
```

http://rubyci.s3.amazonaws.com/debian10/ruby-master/log/20230905T063003Z.log.html.gz
2023-09-05 17:35:28 +09:00
Yusuke Endoh 77db0ca6c8 Prevent a warning: method redefined; discarding old included
```
[ 3463/25719] JSONGeneratorTest#test_string_ext_included_calls_super/home/chkbuild/chkbuild/tmp/build/20230905T063003Z/ruby/test/json/json_generator_test.rb:411: warning: method redefined; discarding old included
/home/chkbuild/chkbuild/tmp/build/20230905T063003Z/ruby/test/json/json_generator_test.rb:399: warning: previous definition of included was here
```

http://rubyci.s3.amazonaws.com/debian10/ruby-master/log/20230905T063003Z.log.html.gz
2023-09-05 17:29:53 +09:00
Hiroshi SHIBATA 923d3517f1 [flori/json] Removed code for Ruby 1.8
https://github.com/flori/json/commit/7f9c29038d
2023-09-05 14:29:46 +09:00
yui-knk 4a90c93427 Pattern matching has not been experimental 2023-09-05 11:52:34 +09:00
Jeremy Evans 3f6c92e9d5 [ruby/rdoc] Omit descriptions and parameter lists for methods defined in C not mentioned in call-seq
This allows RDoc to better generate documentation for methods
following the Ruby core documentation guide (which omits aliases
in call-seq in most cases).  This makes documentation for methods
defined in C more similar to methods defined in Ruby.  For methods
defined in Ruby, the method description of the aliased method is
already not used (you have to explicitly document the alias to
use it).

Internally, this adds AnyMethod#has_call_seq? and #skip_description?,
and updates Darkfish to:

* only show the method name if there is a call-seq for the method,
  but the call-seq omits the method
* to omit the method description if the method is an alias or has
  aliases and has a call-seq that does not include the method

See discussion in https://github.com/ruby/ruby/pull/7316 for
details.

https://github.com/ruby/rdoc/commit/e3688de49b
2023-09-05 00:45:42 +00:00
theo-squadracer a14ba622da [ruby/rdoc] handle symbols declared with `%s`
https://github.com/ruby/rdoc/commit/ed91c4b784
2023-09-05 00:37:30 +00:00
Peter Zhu db3b814cb0 Add debug info for flaky test_warmup_frees_pages
This test sometimes fails with:

```
  1) Failure:
TestProcess#test_warmup_frees_pages [test/ruby/test_process.rb:2751]:
<0> expected but was
<1>.
```

I'm not sure why, so add some debug info.
2023-09-04 14:01:33 -04:00
Yusuke Endoh 4f4c1170bc Revert "Don't reset line coverage for evaled code. (#8330)"
This reverts commit 7e0f5df2f9.

https://bugs.ruby-lang.org/issues/19857#note-7
2023-09-04 19:52:08 +09:00
Samuel Williams 7e0f5df2f9
Don't reset line coverage for evaled code. (#8330)
* Add failing test.
2023-09-04 13:31:25 +12:00
ywenc 2ca0f01015 Add regression tests for start_with?/delete_prefix 2023-09-01 16:23:28 -07:00
Kevin Newton c666077182 [ruby/yarp] Add global variables to the constant pool
https://github.com/ruby/yarp/commit/b48067b067
2023-09-01 22:52:14 +00:00
Peter Zhu d1f83c37f8 Try to fix flaky test for Process.warmup
The test sometimes fails with:

```
  1) Failure:
TestProcess#test_warmup_frees_pages [test/ruby/test_process.rb:2749]:
<0> expected but was
<1>.
```

I think there's a page with an object that needs finalization, so run
GC to clear that object.
2023-09-01 17:48:55 -04:00
Jemma Issroff 95308988b6
[YARP] Implement Compiling for And / Or / Operator Write Nodes (#8352) 2023-09-01 14:20:03 -07:00
Peter Zhu 95def300d2 Fix flaky test for Process.warmup
The test sometimes fails with:

```
  1) Failure:
TestProcess#test_warmup_run_major_gc_and_compact [test/ruby/test_process.rb:2712]:
<2> expected but was
<3>.
```
2023-09-01 15:28:29 -04:00
Mike Dalessio cfe1edddbf [ruby/yarp] fix: report syntax error for invalid hex escape
Closes https://github.com/ruby/yarp/pull/1367

https://github.com/ruby/yarp/commit/b1ab54f526
2023-09-01 17:04:37 +00:00
Mike Dalessio 512f8217cb [ruby/yarp] fix: double-counting of errors in parsing escaped strings
Essentially, this change updates `yp_unescape_calculate_difference` to
not create syntax errors, and we rely entirely on
`yp_unescape_manipulate_string` to report syntax errors.

To do that, this PR adds another (!) parameter to `unescape`:
`yp_list_t *error_list`. When present, `unescape` reports syntax
errors (and otherwise does not).

However, an edge case that needed to be addressed is reporting syntax
errors in this case:

    ?\u{1234 2345}

In a string context, it's possible to have multiple codepoints by
doing something like `"\u{1234 2345}"`; however, in the character
literal context, this is a syntax error -- only a single codepoint is
allowed.

Unfortunately, when `yp_unescape_manipulate_string` is called, there's
nothing to indicate that we are in a "character literal" context and
that only a single codepoint is valid.

To make this work, this PR:

- introduces a new static utility function in yarp.c,
  `yp_char_literal_node_create_and_unescape`, which is called when
  we're parsing `YP_TOKEN_CHARACTER_LITERAL`
- introduces a new (unexported) function,
  `yp_unescape_manipulate_char_literal` which does the same thing as
  `yp_unescape_manipulate_string` but tells `unescape` that only a
  single codepoint is expected

https://github.com/ruby/yarp/commit/f6a65840b5
2023-09-01 17:04:37 +00:00
Benoit Daloze 7f6407c356 [ruby/yarp] Ensure node are present only once in the desugared AST
https://github.com/ruby/yarp/commit/7b090bc23d
2023-09-01 13:18:30 +00:00
Benoit Daloze a21b5a943f [ruby/yarp] Move name_loc before value for LocalVariableWriteNode
* Consistent with ClassVariableWriteNode, ConstantWriteNode, InstanceVariableWriteNode, GlobalVariableWriteNode.
* Fixes desugaring of local variable with operators.

https://github.com/ruby/yarp/commit/9a66737775
2023-09-01 13:18:30 +00:00
Benoit Daloze f1f6f1b39e [ruby/yarp] Make operator_loc the last field for GlobalVariableWriteNode
* Consistent with ClassVariableWriteNode, ConstantWriteNode, InstanceVariableWriteNode, LocalVariableWriteNode.
* Fixes desugaring of global variable with operators.

https://github.com/ruby/yarp/commit/fb5a53fc0b
2023-09-01 13:18:30 +00:00
Benoit Daloze 4172036bc6 [ruby/yarp] Do not desugar Foo::Bar {||,&&,+}= baz as it is incorrect without a temporary variable
* See https://github.com/ruby/yarp/pull/1329#discussion_r1310775433 for details.

https://github.com/ruby/yarp/commit/f0fdcba0c3
2023-09-01 13:18:29 +00:00
yui-knk 45cd011d73 [Bug #19281] Allow semicolon in parenthesis at the first argument of command call
Allow compstmt in the first argument of command call wrapped with parenthesis
like following arguments with parenthesis.
2023-09-01 12:55:09 +09:00
Mike Dalessio df4c77608e [ruby/yarp] fix: octal, hex, and unicode strings at the end of a
file
(https://github.com/ruby/yarp/pull/1371)

* refactor: move EOF check into yp_unescape_calculate_difference

parser_lex is a bit more readable when we can rely on that behavior

* fix: octal and hex digits at the end of a file

Previously this resulted in invalid memory access.

* fix: unicode strings at the end of a file

Previously this resulted in invalid memory access.

* Unterminated curly-bracket unicode is a syntax error

https://github.com/ruby/yarp/commit/21cf11acb5
2023-08-31 22:40:35 +00:00
Nobuyoshi Nakada 9930363aab [Bug-18878] Parse qualified const with brace block as method call 2023-09-01 04:26:31 +09:00
John Hawthorn 43825fba6e YJIT: Handle getblockparamproxy with ifunc
getblockparamproxy for "ifunc" behaves identically to iseq, in just
pushing rb_block_param_proxy.
2023-08-31 10:46:24 -04:00
Jean Boussier 0270210e49 TestSocket_UNIXSocket: stop testing empty packets
OpenBSD and Solaris behave differently here.

Linux does deliver the empty packet, which is questionable
as it's undistinguishable from a closed connection.

It seems that OpenBSD and Solaris simply drop it.

We could test the platform before doing the assertion, but
it would likely be fragile, and the entire web recommend
to not ever send an empty packet, so the value of this
assertion is low.
2023-08-31 16:43:58 +02:00
Peter Zhu 4f0d58260a Correctly calculate initial pages
The old algorithm could calculate an undercount for the initial pages
due to two issues:

1. It did not take into account that some heap pages will have one less
   slot due to alignment. It assumed that every heap page would be able
   to be fully filled with slots. Pages that are unaligned with the slot
   size will lose one slot. The new algorithm assumes that every page
   will be unaligned.
2. It performed integer division, which truncates down. This means that
   the number of pages might not actually satisfy the number of slots.

This can cause the heap to grow in `gc_sweep_finish_size_pool` after
allocating all of the allocatable pages because the total number of
slots would be less than the initial configured number of slots.
2023-08-31 09:28:31 -04:00
Nobuyoshi Nakada c45176dbca
[Bug #19349] Respect `#to_int` of `base` argument 2023-08-31 16:49:58 +09:00
Nobuyoshi Nakada 24b2bb465f
Separate test for `Kernel#Integer` with `base` argument 2023-08-31 16:49:57 +09:00
Peter Zhu 0aa404b957 Change heap init environment variable names
This commit changes RUBY_GC_HEAP_INIT_SIZE_{40,80,160,320,640}_SLOTS to
RUBY_GC_HEAP_{0,1,2,3,4}_INIT_SLOTS. This is easier to use because the
user does not need to determine the slot sizes (which can vary between
32 and 64 bit systems). They now just use the heap names
(`GC.stat_heap.keys`).
2023-08-30 19:37:11 -04:00
Kevin Newton 4aa98b2760 [ruby/yarp] Add a value to numbered references
https://github.com/ruby/yarp/commit/5d9b048971
2023-08-30 21:31:36 +00:00
Jemma Issroff 36786cc381
[YARP] Compile ProgramNode as ScopeNode (#8327)
* [YARP] Compile ProgramNode as ScopeNode
2023-08-30 14:30:42 -07:00
Jemma Issroff f1790fa4e7
[YARP] Fix variables in compilation (#8326)
* [YARP] Fixed several popped instructions

* [YARP] Correctly compiling class path
2023-08-30 14:26:22 -07:00
Mike Dalessio bbaae3681c [ruby/yarp] fix: regular expression with start and end out of order
Also, a similar test and fix for interpolated regular expressions.

This snippet:

    <<-A.g//,
    A
    /{/, ''\

previously created a regular expression node with inverted start and
end:

    RegularExpressionNode(14...13)((14...15), (15...21), (12...13), ", ''", 0),

which failed an assertion during serialization.

After this change:

    RegularExpressionNode(12...15)((14...15), (15...21), (12...13), ", ''", 0),

Found by the fuzzer.

https://github.com/ruby/yarp/commit/5fef572f95
2023-08-30 20:46:09 +00:00
Mike Dalessio 6beaf010a4 [ruby/yarp] fix: binary CallNode with out-of-order arg and receiver
The snippet added in this commit previously resulted in a CallNode
with inverted start and end locations:

    >   AssocNode(15...13)(
    >     CallNode(15...13)(
            StringNode(15...17)((15...16), (16...16), (16...17), ""),
            nil,
            (12...13),
            nil,
            ArgumentsNode(12...13)([MissingNode(12...13)()]),
            nil,
            nil,
            0,
            "/"
          ),
          MissingNode(13...13)(),
          (13...13)
        ),

which failed an assertion during serialization.

After this change, it looks better:

    >   AssocNode(12...13)(
    >     CallNode(12...17)(
            StringNode(15...17)((15...16), (16...16), (16...17), ""),
            nil,
            (12...13),
            nil,
            ArgumentsNode(12...13)([MissingNode(12...13)()]),
            nil,
            nil,
            0,
            "/"
          ),
          MissingNode(13...13)(),
          (13...13)
        ),

Found by the fuzzer.

https://github.com/ruby/yarp/commit/040aa63ad6
2023-08-30 20:46:09 +00:00
Mike Dalessio f80582cda8 [ruby/yarp] fix: StatementsNode with out-of-order body nodes
The presence of the heredocs in this snippet with invalid syntax:

    for <<A + <<B
    A
    B

causes the MissingNode to have a location after other nodes in the
list, resulting in a StatementsNode with inverted start and end
locations:

      [ForNode(0...14)(
         MultiWriteNode(4...7)([InterpolatedStringNode(4...7)((4...7), [], (14...16))], nil, nil, nil, nil),
         MissingNode(16...16)(),
    >    StatementsNode(16...14)(
           [MissingNode(16...16)(), InterpolatedStringNode(10...13)((10...13), [], (16...18)), MissingNode(13...14)()]
         ),
         (0...3),
         (16...16),
         nil,
         (14...14)
       )]

which failed an assertion during serialization.

With this fix, the node's locations are:

      [ForNode(0...14)(
         MultiWriteNode(4...7)([InterpolatedStringNode(4...7)((4...7), [], (14...16))], nil, nil, nil, nil),
         MissingNode(16...16)(),
    >    StatementsNode(10...16)(
           [MissingNode(16...16)(), InterpolatedStringNode(10...13)((10...13), [], (16...18)), MissingNode(13...14)()]
         ),
         (0...3),
         (16...16),
         nil,
         (14...14)
       )]

Found by the fuzzer.

https://github.com/ruby/yarp/commit/09bcedc05e
2023-08-30 20:46:08 +00:00
Kevin Newton cc71e2344b [ruby/yarp] Revisit lex.rake, make lex:rubygems more useable
https://github.com/ruby/yarp/commit/4c76f4a0c0
2023-08-30 20:42:01 +00:00
Kevin Newton c46858fd6a [ruby/yarp] Nest all of the YARP tests under the YARP namespace
https://github.com/ruby/yarp/commit/440cf93a70
2023-08-30 20:41:59 +00:00
Kevin Newton 00dbee94ac [ruby/yarp] Add class variables to the constant pool
https://github.com/ruby/yarp/commit/be5cb60c83
2023-08-30 19:59:28 +00:00
Kevin Newton 151e94fee5 [ruby/yarp] Fix instance variable constant names
https://github.com/ruby/yarp/commit/1f94f55fcb
2023-08-30 19:59:26 +00:00
Kevin Newton 1ed70eb99f [ruby/yarp] Fix unused variable in YARPRubyAPITest
https://github.com/ruby/yarp/commit/0556f971ce
2023-08-30 19:20:21 +00:00
Kevin Newton eac3da173a [ruby/yarp] Fix test-unit API in fuzzer test
https://github.com/ruby/yarp/commit/d24f62566e
2023-08-30 18:36:38 +00:00
Mike Dalessio 2d009805e7 [ruby/yarp] fix: comment followed by whitespace at end of file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/b248553dd6
2023-08-30 18:27:52 +00:00
Mike Dalessio ae7f907559 [ruby/yarp] fix: heredoc with incomplete escape at end of file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/ec4abd87f4
2023-08-30 18:27:51 +00:00
Mike Dalessio 341f47a6dd [ruby/yarp] fix: incomplete escape in regex at the end of file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/55b9dfb41c
2023-08-30 18:27:51 +00:00
Mike Dalessio 7cebb9b737 [ruby/yarp] fix: incomplete escape in list at the end of file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/78ed75ed75
2023-08-30 18:27:51 +00:00
Mike Dalessio 46e47404a8 [ruby/yarp] fix: trailing decimal, binary, octal, and hex numbers at end of file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/af5b85a27a
2023-08-30 18:27:50 +00:00
Mike Dalessio c83552a596 [ruby/yarp] fix: trailing asterisk at end of file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/c86b4907b4
2023-08-30 18:27:49 +00:00
Mike Dalessio bd0268372e [ruby/yarp] fix: trailing comment at end of file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/a1c9404906
2023-08-30 18:27:49 +00:00
Mike Dalessio 6f8126faeb [ruby/yarp] fix: string escape char "\" at the end of a file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/178862e2ca
2023-08-30 18:27:48 +00:00
Mike Dalessio 476f38d62d [ruby/yarp] fix: ":" at the end of a file
Previously this resulted in invalid memory access.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/c781c9fcd2
2023-08-30 18:27:48 +00:00
Mike Dalessio 3da139d284 [ruby/yarp] fix: "$" at the end of a file
Previously this resulted in invalid memory access as well as a
cascading failed assertion:

    src/enc/yp_unicode.c:2224: yp_utf_8_codepoint: Assertion `n >= 1' failed.

Found by the fuzzer.

https://github.com/ruby/yarp/commit/a34c534440
2023-08-30 18:27:47 +00:00
Mike Dalessio 440cdceffb [ruby/yarp] test: new test file for capturing interesting fuzzer snippets
Note that we call `YARP.dump` for these fuzzer tests to better match
the fuzz.parse harness, which also serializes.

https://github.com/ruby/yarp/commit/032ad047e9
2023-08-30 18:27:47 +00:00
Kevin Newton c4998bc3f2 [ruby/yarp] Desugar ||= more accurately
Class variables, global variables, constants, and constant paths
should actually desugar to `defined?` instead of just reading the
value.

https://github.com/ruby/yarp/commit/551a59b876
2023-08-30 16:51:17 +00:00
Kevin Newton 06f54c9a8c
Fix merge error on ruby_api_test.rb 2023-08-30 12:43:56 -04:00
Kevin Newton c5c0a3cf17 [ruby/yarp] Use assert_raise
https://github.com/ruby/yarp/commit/b85e01d77d
2023-08-30 16:10:25 +00:00
Nathan Froyd 9d8d2b81d2 [ruby/yarp] use a more idiomatic form of `assert_raises`
https://github.com/ruby/yarp/commit/687213d2e3
2023-08-30 16:10:25 +00:00
Nobuyoshi Nakada c74039eec7
use assert_raise 2023-08-31 00:38:27 +09:00
Nathan Froyd c521b6f823 [ruby/yarp] add tests for `Location#join`
https://github.com/ruby/yarp/commit/b01711396f
2023-08-30 15:10:24 +00:00
Jean Boussier bcc905100f BasicSocket#recv* return `nil` rather than an empty packet
[Bug #19012]

man recvmsg(2) states:

> Return Value
> These calls return the number of bytes received, or -1 if an error occurred.
> The return value will be 0 when the peer has performed an orderly shutdown.

Not too sure how one is supposed to make the difference between a packet of
size 0 and a closed connection.
2023-08-30 10:07:18 +02:00
Kevin Newton b435161404 [ruby/yarp] Add instance variable names to the constant pool
https://github.com/ruby/yarp/commit/f049932c44
2023-08-29 20:12:57 +00:00
Kevin Newton 455153705c Tests for the YARP compiler 2023-08-29 15:53:25 -04:00
Kevin Newton 5161c6c4cd [ruby/yarp] Statements inside ensure blocks can accept blocks
https://github.com/ruby/yarp/commit/be84ea5343
2023-08-29 19:33:31 +00:00
Stan Lo f37f357e80 [ruby/irb] Improve help/show_cmds message during debugger
integration
(https://github.com/ruby/irb/pull/693)

* `help` should display debugger's help during irb:rdbg session

* Update `show_cmds`'s output when in irb:rdbg session

https://github.com/ruby/irb/commit/4029c2e564
2023-08-29 18:36:16 +00:00
tomoya ishida 062eec7558 [ruby/irb] Add --nomultiline indent and prompt test
(https://github.com/ruby/irb/pull/699)

https://github.com/ruby/irb/commit/9b4aea753b
2023-08-29 15:34:49 +00:00
Stan Lo 0cfb779692 [ruby/irb] Fix test warnings (https://github.com/ruby/irb/pull/698)
* Encoding should be saved before creating Irb objects

* Fix unused local warning

https://github.com/ruby/irb/commit/036ec31034
2023-08-29 12:48:33 +00:00
Sutou Kouhei 0a219ef44a
jruby: Add StringIO::VERSION (#59)
Fixes GH-57
2023-08-29 18:15:05 +09:00
Stan Lo 221c2d0e19
[ruby/irb] Print deprecation message for prompt_n methods
(https://github.com/ruby/irb/pull/691)

They were removed in #685, but we should still keep them to avoid breaking
changes to tools like Chef.

533ff08947/lib/chef/shell.rb (L138)

https://github.com/ruby/irb/commit/b585e0c835
2023-08-29 18:15:05 +09:00
Summer ☀️ 0cd92819c9
[ruby/irb] Remove unused `PROMPT_N`
(https://github.com/ruby/irb/pull/685)

https://github.com/ruby/irb/commit/66e69fa0dc
2023-08-29 18:15:05 +09:00
Kouhei Yanagita a28c5151f5 Fix Array#bsearch when block returns a non-integer numeric value 2023-08-29 18:00:44 +09:00
Samuel Williams 901b6d9c50
Validate the typed data before dereferencing the internal struct. (#8315) 2023-08-29 20:04:14 +12:00
Nobuyoshi Nakada 7e5c662a6f
[Feature #18183] Add `chars:` option to `Random#alphanumeric` 2023-08-29 10:56:56 +09:00
Peter Zhu fd0df1f8c6 Fix growth in minor GC when we have initial slots
If initial slots is set, then during a minor GC, if we have allocatable
pages but the heap is mostly full, then we will set `grow_heap` to true
since `total_slots` does not count allocatable pages so it will be less
than `init_slots`. This can cause `allocatable_pages` to grow to much
higher than desired since it will appear that the heap is mostly full.
2023-08-28 18:01:29 -04:00
Peter Zhu 91de37c23e Remove --disable-gems in assert_in_out_err
assert_in_out_err adds --disable=gems so we don't need to add
--disable-gems in the args list.
2023-08-28 15:05:19 -04:00
Mike Dalessio 9b87518ea0 [ruby/yarp] fix: %I list spanning a heredoc
Similar to the previous %W fix, we accept a symbol node and
concatenate it onto an interpolated symbol.

https://github.com/ruby/yarp/commit/6b5911b95e
2023-08-28 12:37:31 +00:00
Mike Dalessio 29c5b85128 [ruby/yarp] fix: %i list spanning a heredoc
The fix here is similar to what we did in a previous commit for %w, to
accept two consecutive string tokens without a separator.

https://github.com/ruby/yarp/commit/f869fbdbe5
2023-08-28 12:37:30 +00:00
Mike Dalessio 74812df496 [ruby/yarp] fix: %W list spanning a heredoc
Primarily this fix is to accept a string node and concatenate it onto
an interpolated string.

https://github.com/ruby/yarp/commit/6df729fe72
2023-08-28 12:37:30 +00:00
Mike Dalessio 77e971b6ec [ruby/yarp] fix: %w list spanning a heredoc
Two fixes were necessary:

- ensure we are handling newlines correctly
- accept two consecutive string tokens without a separator

https://github.com/ruby/yarp/commit/4e707937cb

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2023-08-28 12:37:29 +00:00
Mike Dalessio 8926fd20f6 [ruby/yarp] test: backfill tests for %q/%Q spanning a heredoc
Also rename the fixture file

https://github.com/ruby/yarp/commit/c148d955fd
2023-08-28 12:37:28 +00:00
Mike Dalessio 06f5d8f3a0 [ruby/yarp] Improve how we declare ripper exceptions in parse_test.rb
Specific files are named earlier in the block, and we now have the
ability to skip just the lex matching, or skip ripper entirely (for
files that don't parse).

https://github.com/ruby/yarp/commit/dcd3806dca
2023-08-28 12:37:28 +00:00
Jun Aruga 69d9fda9f5 [ruby/openssl] Remove the pending logics by the pend_on_openssl_issue_21493.
Because we will add a workaround to avoid this issue.

https://github.com/ruby/openssl/commit/d157ba1d3b
2023-08-28 12:05:32 +09:00
Benoit Daloze 412e586afe [ruby/yarp] Fix paths in library_symbols_test.rb
https://github.com/ruby/yarp/commit/b5fba6d63f
2023-08-27 16:18:15 +00:00
Peter Zhu b7237e3bbd Free all empty heap pages in Process.warmup
This commit adds `free_empty_pages` which frees all empty heap pages and
moves the number of pages freed to the allocatable pages counter. This
is used in Process.warmup to improve performance because page
invalidation from copy-on-write is slower than allocating a new page.
2023-08-27 09:39:29 -04:00
Peter Zhu a97dedf761 [ruby/irb] Fix deprecation test when ran multiple times
(https://github.com/ruby/irb/pull/695)

https://github.com/ruby/irb/commit/ae0e5bb80f
2023-08-26 13:56:51 +00:00
Peter Zhu 9ea9f99248 [Feature #19785] Deprecate RUBY_GC_HEAP_INIT_SLOTS
This environment variable is replaced by
`RUBY_GC_HEAP_INIT_SIZE_%d_SLOTS`, so it doesn't make sense to keep it.
2023-08-25 21:50:56 -04:00
Nobuyoshi Nakada b054c2fe06 [Bug #19784] Fix behaviors against prefix with broken encoding
- String#start_with?
- String#delete_prefix
- String#delete_prefix!
2023-08-26 08:58:02 +09:00
Nobuyoshi Nakada 808b067088 Split string tests 2023-08-26 08:58:02 +09:00
Takashi Kokubun 96a809f621 Use require_relative in JSON tests
to prevent them from conflicting with yarp/test_helper
2023-08-25 15:32:14 -07:00
Kevin Newton ca9a44795b Remove version templating in YARP 2023-08-25 18:20:51 -04:00
Kevin Newton 439f069b4b [ruby/yarp] Move tests from test/* to test/yarp/* to match CRuby
This should make it easier on the sync to determine what changed
and hopefully result in fewer merge conflicts that have to be
manually resolved.

https://github.com/ruby/yarp/commit/17d82afbfc
2023-08-25 21:15:49 +00:00
Kevin Newton 9b8602dd90 [ruby/yarp] Introduce parse_lex instead of asking for a block
https://github.com/ruby/yarp/commit/7e70339fe1
2023-08-25 21:10:19 +00:00
Kevin Newton 0c1a749eef [ruby/yarp] Fix nested multi assignment locations
https://github.com/ruby/yarp/commit/9a65f002dc
2023-08-25 21:10:16 +00:00
Kevin Newton 55a8add304 [ruby/yarp] Fix rational parsing
https://github.com/ruby/yarp/commit/c8f31eb5b6
2023-08-25 21:10:15 +00:00