Issue #19273 has been reported by taichi730 (Taichi Ishitani).
----------------------------------------
Bug #19273: [Regexp] regexp does not does not match expected
https://bugs.ruby-lang.org/issues/19273
* Author: taichi730 (Taichi Ishitani)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
A regexp pattern does not match expected with Ruby 3.2.
Ruby 3.2
``` ruby
pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/
"10:0:0".mathc(pattern) #=> #<MatchData "10">
"0:0:0".match(pattern) #=> #<MatchData "0:0:0">
```
String "10.0.0" is only partially matched but not all of it.
Ruby 3.1.0:
```ruby
pattern = /(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))(?::(?-mix:(?i-mx:[+-]?0b[01](?:_?[01])*)|(?-mix:[+-]?(?:[1-9]_?(?:\d_?)*)?\d)|(?i-mx:[+-]?0x\h(?:_?\h)*))){0,3}/
"10:0:0".match(pattern) #=> #<MatchData "10:0:0">
"0:0:0".match(pattern) #=> #<MatchData "0:0:0">
```
Both strings matches with the regexp wholy.
--
https://bugs.ruby-lang.org/
Issue #19263 has been reported by k0kubun (Takashi Kokubun).
----------------------------------------
Bug #19263: MJIT fails to compile multiple values in a single case in Ruby 3.2.0
https://bugs.ruby-lang.org/issues/19263
* Author: k0kubun (Takashi Kokubun)
* Status: Open
* Priority: Normal
* Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED
----------------------------------------
```
$ cat test.rb
def test(a)
case a
when true, false
a
end
end
test(true)
test(true)
$ ruby --mjit-verbose=1 --mjit-wait --mjit-call-threshold=2 test.rb
/tmp/_ruby_mjit_p237606u1.c: In function ‘_mjit0’:
/tmp/_ruby_mjit_p237606u1.c:58:7: error: duplicate case value
58 | case 19:
| ^~~~
compilation terminated due to -Wfatal-errors.
Successful MJIT finish
```
I'd like to fix this in master and ask the branch maintainer to backport this to 3.2.1.
--
https://bugs.ruby-lang.org/
Issue #18743 has been updated by marcper (Marcelo Pereira).
Good evening, @matz. The PR with the bug fix is available now for a few months. Please advise on the next steps.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-100867
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
Issue #19277 has been reported by georgeclaghorn (George Claghorn).
----------------------------------------
Feature #19277: Project-scoped refinements
https://bugs.ruby-lang.org/issues/19277
* Author: georgeclaghorn (George Claghorn)
* Status: Open
* Priority: Normal
----------------------------------------
Refinements are a great way to isolate patches to the files that rely on them. Nonetheless, I believe the need to explicitly enable refinements in every file that uses them has hindered their adoption. As an inciting example, it’s hard to imagine Rails adopting refinements in their current form and requiring `using` calls for Active Support core extensions throughout Rails applications.
I’d like to propose a middle way: allowing a Ruby project (a gem, library, application, etc.) to enable refinements for all of its Ruby files. This would combine the isolation benefits of refinements with the convenience of global monkey-patches.
#### Projects
To do this, we must decide how to identify projects and how they specify their desired refinements. A Ruby project is a directory containing a project configuration file with a special name. (I am intentionally not proposing a specific name for the file here. One will need to be chosen eventually, and suggestions are welcome.) A project configuration file is in Ruby format.
When Ruby loads a script from a file, it searches upwards from the current directory for a project configuration file. For reasons of performance, project configurations may be cached by project root path. The search for a project configuration would end when a configuration for a particular path prefix is found in the cache.
When a project configuration is found, it is evaluated as though it were prepended to the beginning of the currently-loading file. Alternatively, a limited DSL could be provided to the configuration file that prepares interpreter state for the currently-loading file.
Below is an example project configuration:
```ruby
require "prestige/refinements"
using Prestige::Refinements
```
For `ruby -e` and `irb`, the project configuration is searched for beginning from the current working directory.
For `Kernel#eval`, the current file’s project configuration is used.
#### Concerns
* Performance, mainly. This is a significant amount of work to add to hot code paths. I believe the cost could be minimized with sensible caching, though not completely eliminated. I haven’t started implementing this and don’t have measurements of the actual cost yet.
* Ergonomics. Is this the best way to provide project-scoped refinements? Is the project configuration format appropriate?
--
https://bugs.ruby-lang.org/
Issue #18797 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Closed to Open
Pull request submitted to remove support for the 3rd argument: https://github.com/ruby/ruby/pull/7039
----------------------------------------
Bug #18797: Third argument to Regexp.new is a bit broken
https://bugs.ruby-lang.org/issues/18797#change-100850
* Author: janosch-x (Janosch Müller)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
## Situation
'n' or 'N' can be passed as a third argument to `Regexp.new`. However, the behavior is not the same as the literal `n`-flag or the `Regexp::NOENCODING` option, and it makes the `#encoding` of `Regexp` and `Regexp#source` diverge:
```ruby
/😅/n # => SyntaxError
Regexp.new('😅', Regexp::NOENCODING) # => RegexpError
re = Regexp.new('😅', nil, 'n') # => /😅/
re.options == Regexp::NOENCODING # => true
re.encoding # => ASCII-8BIT
re.source.encoding # => UTF-8
re =~ '😅' # => Encoding::CompatibilityError
```
## Code
[Here](https://github.com/ruby/ruby/blob/b41de3a1e8c36a5cc336b6f7cd3cb71126c…. There is also a test for the resulting encoding [here](https://github.com/ruby/ruby/blob/cf2bbcfff2985c116552967c7c4522f4630…, but it is a no-op because the whole file is set to that encoding via magic comment anyway.
The third argument was added when ASCII was still the default Ruby encoding, so I guess Regexp and source encoding still matched at that point.
## Solution
It could be fixed, but my impression is that it is not useful anymore.
It was probably only added because `Regexp::NOENCODING` wasn't available at the time, so I think it could be deprecated like so:
> Passing a third argument to Regexp.new is deprecated. Use `Regexp::NOENCODING` as second argument instead.
--
https://bugs.ruby-lang.org/
Issue #19274 has been reported by aalllop (Alberto Allegue).
----------------------------------------
Bug #19274: Error installing ruby 3.2.0 on RH 8
https://bugs.ruby-lang.org/issues/19274
* Author: aalllop (Alberto Allegue)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
When I execute rvm install 3.2.0 the installation fails with the next error:
installing default gems from lib: /var/lib/jenkins/.rvm/rubies/ruby-3.2.0-rc1/lib/ruby/gems/3.2.0+3
abbrev 0.1.0
base64 0.1.1
benchmark 0.2.1
bundler 2.4.0.dev
<internal:/var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- psych (LoadError)
from <internal:/var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems.rb:610:in `load_yaml'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/config_file.rb:346:in `load_file'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/config_file.rb:189:in `initialize'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems.rb:331:in `new'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems.rb:331:in `configuration'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/user_interaction.rb:167:in `verbose'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/installer.rb:544:in `generate_bin_script'
from ./tool/rbinstall.rb:891:in `generate_bin_script'
from ./tool/rbinstall.rb:855:in `generate_bin_script'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/installer.rb:506:in `block in generate_bin'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/installer.rb:490:in `each'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/installer.rb:490:in `generate_bin'
from /var/lib/jenkins/.rvm/src/ruby-3.2.0-rc1/lib/rubygems/installer.rb:331:in `install'
from ./tool/rbinstall.rb:881:in `block in install'
from ./tool/rbinstall.rb:721:in `no_write'
from ./tool/rbinstall.rb:881:in `install'
from ./tool/rbinstall.rb:989:in `block in install_default_gem'
from ./tool/rbinstall.rb:976:in `each'
from ./tool/rbinstall.rb:976:in `install_default_gem'
from ./tool/rbinstall.rb:913:in `block in <main>'
from ./tool/rbinstall.rb:1077:in `block in <main>'
from ./tool/rbinstall.rb:1074:in `each'
from ./tool/rbinstall.rb:1074:in `<main>'
make: *** [uncommon.mk:415: do-install-nodoc] Error 1
++ return 2
--
https://bugs.ruby-lang.org/
Issue #19267 has been reported by cfis (Charlie Savage).
----------------------------------------
Bug #19267: Compile fails when enabling YJIT on x64-mingw-ucrt
https://bugs.ruby-lang.org/issues/19267
* Author: cfis (Charlie Savage)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x64-mingw-ucrt]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
Ruby fails to compile with msys2/ucrt64 when enabling yjit.
Error:
``` c
In file included from ./include/ruby/defines.h:72,
from ./include/ruby/ruby.h:25,
from eval_intern.h:4,
from vm.c:13:
vm.c: In function 'mjit_check_iseq':
vm.c:393:12: warning: implicit declaration of function 'MJIT_FUNC_STATE_P' [-Wimplicit-function-declaration]
393 | ASSUME(MJIT_FUNC_STATE_P(mjit_state));
| ^~~~~~~~~~~~~~~~~
./include/ruby/backward/2/assume.h:43:46: note: in definition of macro 'RB_LIKELY'
43 | # define RB_LIKELY(x) (__builtin_expect(!!(x), 1))
| ^
./include/ruby/backward/2/assume.h:27:28: note: in expansion of macro 'RBIMPL_ASSUME'
27 | #define ASSUME RBIMPL_ASSUME /**< @old{RBIMPL_ASSUME} */
| ^~~~~~~~~~~~~
vm.c:393:5: note: in expansion of macro 'ASSUME'
393 | ASSUME(MJIT_FUNC_STATE_P(mjit_state));
| ^~~~~~
vm.c:394:19: error: conversion to incomplete type
394 | switch ((enum rb_mjit_func_state)mjit_state) {
| ^~~~~~~~~~~~~~~~~~
vm.c:395:12: error: 'MJIT_FUNC_NOT_COMPILED' undeclared (first use in this function)
395 | case MJIT_FUNC_NOT_COMPILED:
```
The problem:
In ruby-3.2.0\.ext\include\x64-mingw-ucrt\ruby\config.h
``` c
#define USE_MJIT 0
#define USE_YJIT 1
```
But in mjit.h:
``` c
# if USE_MJIT
...
// Return true if jit_func is part of enum rb_mjit_func_state
#define MJIT_FUNC_STATE_P(jit_func) ((uintptr_t)(jit_func) <= (uintptr_t)MJIT_FUNC_FAILED)
...
# end
```
So MJIT_FUNC_STATE_P is never defined.
Then in vm.c:
``` c
#if USE_MJIT || USE_YJIT
# ifdef MJIT_HEADER
NOINLINE(static COLDFUNC VALUE mjit_check_iseq(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body));
# else
static inline VALUE mjit_check_iseq(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body);
# endif
static VALUE
mjit_check_iseq(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body)
{
uintptr_t mjit_state = (uintptr_t)(body->jit_func);
ASSUME(MJIT_FUNC_STATE_P(mjit_state));
etc
```
Note that MJIT_HEADER is not defined.
Note this is just the first of many errors that you will encounter.
To get Ruby 3.2.0 to compile, I had to do a significant rearrangement of mjit.h which I have attached.
However, when yjit.c then compiles:
``` c
yjit.c: In function 'rb_yjit_mark_unused':
yjit.c:93:5: warning: implicit declaration of function 'madvise'; did you mean 'raise'? [-Wimplicit-function-declaratio
]
93 | madvise(mem_block, mem_size, MADV_DONTNEED);
| ^~~~~~~
| raise
yjit.c:93:34: error: 'MADV_DONTNEED' undeclared (first use in this function)
93 | madvise(mem_block, mem_size, MADV_DONTNEED);
```
This is because the check in yjit.c (line 32) is:
``` c
// For mmapp(), sysconf()
#if defined _WIN32
#include <unistd.h>
#include <sys/mman.h>
#endif
```
UCRT doesn't define _WIN32, it defines _WIN64
However, then the next issue - there is no sys/mman.h header with mingw.
So enabling yjit on mingw breaks the compile and is apparently unsupported.
---Files--------------------------------
mjit.h (5.71 KB)
--
https://bugs.ruby-lang.org/