83482 Commits

Author SHA1 Message Date
Peter Zhu
11ffee88b5 Replace assert with RUBY_ASSERT in darray.h
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-12 15:07:47 -05:00
Peter Zhu
7256e38f86 Replace assert with RUBY_ASSERT in complex.c
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-12 15:07:47 -05:00
Peter Zhu
de7a29ef8d Replace assert with RUBY_ASSERT in compile.c
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-12 15:07:47 -05:00
Peter Zhu
6906e502f9 Replace assert with RUBY_ASSERT in bignum.c
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-12 15:07:47 -05:00
Peter Zhu
1228751af6 Replace assert with RUBY_ASSERT in array.c
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-12 15:07:47 -05:00
Peter Zhu
ac38f259aa Replace assert with RUBY_ASSERT in string.c
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-12 15:07:47 -05:00
Kevin Newton
bb845ae879 [ruby/prism] Fix typo in class variable name error
https://github.com/ruby/prism/commit/5f6c45f6fb
2024-02-12 20:03:09 +00:00
Burdette Lamar
4f1a466522
More on auto-link (#9907) 2024-02-12 15:01:46 -05:00
Nobuyoshi Nakada
84d8dbe7a5 Enable redefinition check for rbinc methods 2024-02-12 11:51:06 -08:00
Kevin Newton
1395838e18 [PRISM] Check full lines for invalid UTF-8 2024-02-12 14:48:09 -05:00
Alan Wu
2131d04f43 YJIT: Add support for **kwrest parameters
Now that `...` uses `**kwrest` instead of regular splat and
ruby2keywords, we need to support these type of methods to
support `...` well.
2024-02-12 13:57:24 -05:00
tomoya ishida
7af97dc71f [ruby/irb] Powerup show_source by enabling RubyVM.keep_script_lines
(https://github.com/ruby/irb/pull/862)

* Powerup show_source by enabling RubyVM.keep_script_lines

* Add file_content field to avoid reading file twice while show_source

* Change path passed to eval, don't change irb_path.

* Encapsulate source coloring logic and binary file check insode class Source

* Add edit command testcase when irb_path does not exist

* Memoize irb_path existence to reduce file existence check calculating eval_path

https://github.com/ruby/irb/commit/239683a937
2024-02-12 18:38:30 +00:00
Alan Wu
e878bbd641 Allow foo(**nil, &block_arg)
Previously, `**nil` by itself worked, but if you add a block argument,
it raised a conversion error. The presence of the block argument
shouldn't change how keyword splat works.

See: <https://bugs.ruby-lang.org/issues/20064>
2024-02-12 13:02:50 -05:00
Kevin Newton
e08c128417 [ruby/prism] Error messages closer to CRuby
https://github.com/ruby/prism/commit/19ffa0b980
2024-02-12 18:01:45 +00:00
Takashi Kokubun
e4d3e652ff
YJIT: Prefer an overloaded cme if available (#9913)
YJIT: Prefer an overloaded cme if applicable
2024-02-12 12:56:44 -05:00
Kevin Newton
94bc5ad30a [ruby/prism] ruby_parser translator
https://github.com/ruby/prism/commit/1925b970c7
2024-02-12 17:54:54 +00:00
Jean Boussier
de1a586ecc proc.c: get rid of CLONESETUP
[Bug #20253]

All the way down to Ruby 1.9, `Proc`, `Method`, `UnboundMethod`
and `Binding` always had their own specific clone and dup routine.

This caused various discrepancies with how other objects behave
on `dup` and `clone. [Bug #20250], [Bug #20253].

This commit get rid of `CLONESETUP` and use the the same codepath
as all other types, so ensure consistency.

NB: It's still not accepting the `freeze` keyword argument on `clone`.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-02-12 18:31:48 +01:00
Takashi Kokubun
c04782c2cb
YJIT: Adjust the padding size of counts automatically (#9912) 2024-02-12 11:56:24 -05:00
Takashi Kokubun
b9f25b100f
YJIT: Fix insufficient type guards (#9911) 2024-02-12 11:55:52 -05:00
Kevin Newton
c3886c12dc [ruby/prism] Fix unary not location
https://github.com/ruby/prism/commit/861689f6d1
2024-02-12 16:27:49 +00:00
Noah Gibbs
16b39072a5 [ruby/prism] Move Prism::RipperCompat to Prism::Translation::Ripper
https://github.com/ruby/prism/commit/c0331abe4f
2024-02-12 15:57:57 +00:00
Kevin Newton
78deba1aa1 [ruby/prism] Unary not name location
https://github.com/ruby/prism/commit/78190d2999
2024-02-12 15:57:17 +00:00
Nobuyoshi Nakada
739eec0456
[DOC] :stopdoc: directive must be on its own line (#9916) 2024-02-12 10:48:10 -05:00
Peter Zhu
190a55d27f Drill newobj cache instead of ractor 2024-02-12 09:43:38 -05:00
Benoit Daloze
d4a6c6521a Try nmake install before nmake test-spec 2024-02-12 14:31:34 +01:00
tomoya ishida
06995eb45b [ruby/irb] Fix exit! command warning and method behavior
(https://github.com/ruby/irb/pull/868)

* Fix exit! command warning and method behavior

* Remove arg(0) from Kernel.exit and Kernel.exit!

https://github.com/ruby/irb/commit/372bc59bf5
2024-02-12 11:28:54 +00:00
Benoit Daloze
39788e5888 Try prepare-gems instead of extract-gems
* `make install` uses prepare-gems.
2024-02-12 11:33:19 +01:00
Benoit Daloze
ffe1a68bda Skip spec failing on i686 2024-02-12 11:33:08 +01:00
Benoit Daloze
d15301d482 Exclude a problematic spec when run in CRuby via make test-spec until fixed 2024-02-12 11:05:51 +01:00
Benoit Daloze
b19d2409be Update to ruby/spec@ce834ad 2024-02-12 10:56:33 +01:00
Benoit Daloze
90a746d246 Always extract bundled gems before running ruby/spec
* Fixes 44d74f22c8 (r138276491)
2024-02-12 10:55:57 +01:00
yui-knk
7fc89a9262 Use Node for warn_duplicate_keys st_table keys 2024-02-12 17:46:22 +09:00
Nobuyoshi Nakada
4f7de1dcdd
Adjust styles [ci skip] 2024-02-12 16:50:30 +09:00
Jeremy Evans
c20e819e8b Fix crash when passing large keyword splat to method accepting keywords and keyword splat
The following code previously caused a crash:

```ruby
h = {}
1000000.times{|i| h[i.to_s.to_sym] = i}
def f(kw: 1, **kws) end
f(**h)
```

Inside a thread or fiber, the size of the keyword splat could be much smaller
and still cause a crash.

I found this issue while optimizing method calling by reducing implicit
allocations.  Given the following code:

```ruby
def f(kw: , **kws) end
kw = {kw: 1}
f(**kw)
```

The `f(**kw)` call previously allocated two hashes callee side instead of a
single hash.  This is because `setup_parameters_complex` would extract the
keywords from the keyword splat hash to the C stack, to attempt to mirror
the case when literal keywords are passed without a keyword splat.  Then,
`make_rest_kw_hash` would build a new hash based on the extracted keywords
that weren't used for literal keywords.

Switch the implementation so that if a keyword splat is passed, literal keywords
are deleted from the keyword splat hash (or a copy of the hash if the hash is
not mutable).

In addition to avoiding the crash, this new approach is much more
efficient in all cases.  With the included benchmark:

```
                                1
            miniruby:   5247879.9 i/s
     miniruby-before:   2474050.2 i/s - 2.12x  slower

                        1_mutable
            miniruby:   1797036.5 i/s
     miniruby-before:   1239543.3 i/s - 1.45x  slower

                               10
            miniruby:   1094750.1 i/s
     miniruby-before:    365529.6 i/s - 2.99x  slower

                       10_mutable
            miniruby:    407781.7 i/s
     miniruby-before:    225364.0 i/s - 1.81x  slower

                              100
            miniruby:    100992.3 i/s
     miniruby-before:     32703.6 i/s - 3.09x  slower

                      100_mutable
            miniruby:     40092.3 i/s
     miniruby-before:     21266.9 i/s - 1.89x  slower

                             1000
            miniruby:     21694.2 i/s
     miniruby-before:      4949.8 i/s - 4.38x  slower

                     1000_mutable
            miniruby:      5819.5 i/s
     miniruby-before:      2995.0 i/s - 1.94x  slower
```
2024-02-11 22:48:38 -08:00
yui-knk
93accfdf48 Fix [BUG] unknown node for NODE_ENCODING
It should be `return` instead of `break`, otherwise
`[BUG] dump_node: unknown node: NODE_ENCODING` happens.
2024-02-12 14:49:07 +09:00
KJ Tsanaktsidis
697ade7bda Update ASAN docs to reflect the current state of things
I don't really think ASAN works well at all on any version of Ruby from
before https://bugs.ruby-lang.org/issues/20001 was landed. Update the
docs to clarify what works, and what does not work.

Also there's no need to compile at `-O0`; this was probably just hiding
some of the problems with our stack scanning that were fixed in the
above issue.

[Bug #20248]
2024-02-12 10:52:05 +11:00
KJ Tsanaktsidis
1d467f2255 Burn default ASAN options into the built Ruby
* We always need use_sigaltstack=0 because Ruby registers sigaltstack
  handlers
* We also need to disable leak detection (unless RUBY_FREE_AT_EXIT is
  set - I might experiment later with automatically enabling leak
  detection if RUBY_FREE_AT_EXIT is set).

Burning it into the built ruby binary in this way avoids people needing
to remember to start their Ruby program with these flags all the time.

We also need a small fix in mkmf to make sure that test programs also
don't have leak detection enabled (this is never desirable)

[Bug #20256]
2024-02-12 10:51:46 +11:00
Nobuyoshi Nakada
c9006ddb88 [ruby/optparse] [DOC] Add description of OptionParser#define_by_keywords
https://github.com/ruby/optparse/commit/451dea51a0
2024-02-11 16:55:41 +00:00
Nobuyoshi Nakada
a63a0c247b
Win32: Include stdio.h for printf 2024-02-12 01:09:51 +09:00
Nobuyoshi Nakada
bbccabe6d6 [ruby/optparse] [DOC] Add missing documents
https://github.com/ruby/optparse/commit/33956ce93f
2024-02-11 16:08:14 +00:00
eileencodes
a3ceb69168 [PRISM] Fix error handling in pm_parse_prism
Following changes made in ruby/prism#2365 this implements error handling
for when `pm_string_mapped_init` returns `false`.

Related: ruby/prism#2207
2024-02-11 09:41:20 -05:00
Nobuyoshi Nakada
90fe1b4402
Win32: Use TARGET_OS for word-size
It is derived from `_WIN64` pre-defined macro, at `-osname-` in
win32/setup.mak.
2024-02-11 22:00:12 +09:00
Nobuyoshi Nakada
603392b8d4
Win32: Use prototype 2024-02-11 20:55:26 +09:00
Nobuyoshi Nakada
ea2ea74a26
Win32: Copy coroutine no longer exists
At 42130a64f02294dc8025af3a51bda518c67ab33d, it has been replaced with
pthread implementation.
2024-02-11 20:03:18 +09:00
Nobuyoshi Nakada
c77f736bc1
Win32: Fix pre-defined macros for platforms
Use `_WIN64` for word-size, `_M_AMD64` for CPU-specific feature.
2024-02-11 19:43:06 +09:00
Nobuyoshi Nakada
aa36e44c05
Win32: Define HAVE_INTTYPES_H
Suppress redefinition warnings, inttypes.h has been provided as well
as stdint.h since `_MSC_VER` 1600 (= Visual C++ 10.0 = Visual Studio
2010).

```
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\inttypes.h(123): warning C4005: 'PRIdPTR': macro redefinition
D:\a\ruby\ruby\src\include\ruby/backward/2/inttypes.h(51): note: see previous definition of 'PRIdPTR'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\inttypes.h(142): warning C4005: 'PRIiPTR': macro redefinition
D:\a\ruby\ruby\src\include\ruby/backward/2/inttypes.h(52): note: see previous definition of 'PRIiPTR'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\inttypes.h(161): warning C4005: 'PRIoPTR': macro redefinition
D:\a\ruby\ruby\src\include\ruby/backward/2/inttypes.h(53): note: see previous definition of 'PRIoPTR'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\inttypes.h(180): warning C4005: 'PRIuPTR': macro redefinition
D:\a\ruby\ruby\src\include\ruby/backward/2/inttypes.h(54): note: see previous definition of 'PRIuPTR'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\inttypes.h(199): warning C4005: 'PRIxPTR': macro redefinition
D:\a\ruby\ruby\src\include\ruby/backward/2/inttypes.h(55): note: see previous definition of 'PRIxPTR'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\inttypes.h(218): warning C4005: 'PRIXPTR': macro redefinition
D:\a\ruby\ruby\src\include\ruby/backward/2/inttypes.h(56): note: see previous definition of 'PRIXPTR'
```
2024-02-11 19:34:13 +09:00
Stan Lo
5c4657f883 [ruby/irb] Polish the exit! command and its tests
(https://github.com/ruby/irb/pull/867)

* Remove IRB.irb_exit! method

It's not necessary to introduce a new method just for the exit! command
at this moment.

* Rename ExitForcedAction to ForceExit

* Move force exit tests to a dedicated file

* Fix nested history saving with exit! command

Because we switched to use `Kernel#exit` instead of `exit!`, the outer
session's ensure block in `Irb#run` will be run, which will save the
history. This means the separate check to save history when force exiting
is no longer necessary.

* execute_lines helper should also capture IRB setup's output

This prevents setup warnings from being printed to test output
while allowing those output to be tested.

* Update readme

https://github.com/ruby/irb/commit/899d10ade1
2024-02-11 05:17:40 +00:00
Ignacio Chiazzo Cardarello
429eeb09f2 [ruby/irb] Introduce exit! command
(https://github.com/ruby/irb/pull/851)

* Added failing test for when writing history on exit

* Save history on exit

* Exit early when calling Kernel.exit

* use status 0 for kernel.exit

* Added test for nested sessions

* Update lib/irb.rb

---------

https://github.com/ruby/irb/commit/c0a5f31679

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-02-10 22:07:53 +00:00
Nobuyoshi Nakada
f960fbc102 [ruby/optparse] Search exactly when require_exact
To work with options defined as `--[no]-something`.

Fix https://bugs.ruby-lang.org/issues/20252
Fix https://github.com/ruby/optparse/pull/60

https://github.com/ruby/optparse/commit/78afdab307
2024-02-11 00:47:41 +09:00
yui-knk
fdd92c2d61 Fix the variable to be checked
It should check the result of `rb_parser_search_nonascii`.
2024-02-10 18:58:42 +09:00