ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:123141] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
@ 2025-08-31  2:54 niku (niku _) via ruby-core
  2025-08-31  4:25 ` [ruby-core:123142] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: niku (niku _) via ruby-core @ 2025-08-31  2:54 UTC (permalink / raw)
  To: ruby-core; +Cc: niku (niku _)

Issue #21558 has been reported by niku (niku _).

----------------------------------------
Bug #21558: Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
https://bugs.ruby-lang.org/issues/21558

* Author: niku (niku _)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-08-30T18:24:25Z master 5c7dfe85a1) +PRISM [arm64-darwin24]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Regexp.union returns a non-shareable object when given multiple Regex arguments. Is this expected behavior?
It would be preferable if the resulting Regexp were shareable, since single-argument `Regexp.union` does produce a shareable object.

```irb
irb(main):001> a = /a/
=> /a/
irb(main):002> b = Regexp.union(a)
=> /a/
irb(main):003> c = Regexp.union(a, a)
=> /(?-mix:a)|(?-mix:a)/
irb(main):004> Ractor.shareable?(a)
=> true
irb(main):005> Ractor.shareable?(b)
=> true
irb(main):006> Ractor.shareable?(c)
=> false
```





-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:123142] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
  2025-08-31  2:54 [ruby-core:123141] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible) niku (niku _) via ruby-core
@ 2025-08-31  4:25 ` nobu (Nobuyoshi Nakada) via ruby-core
  2025-08-31  4:42 ` [ruby-core:123143] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-08-31  4:25 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21558 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Open to Feedback

`Regexp.union` creates a new instance, except for a single `Regexp` argument case.
And it is impossible to revert a Ractor-shareable object to non-Ractor-shareable.
So it feels natural that the new instance is not Ractor-shareable as well as `String.new` and others, to me.

----------------------------------------
Bug #21558: Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
https://bugs.ruby-lang.org/issues/21558#change-114475

* Author: niku (niku _)
* Status: Feedback
* ruby -v: ruby 3.5.0dev (2025-08-30T18:24:25Z master 5c7dfe85a1) +PRISM [arm64-darwin24]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Regexp.union returns a non-shareable object when given multiple Regex arguments. Is this expected behavior?
It would be preferable if the resulting Regexp were shareable, since single-argument `Regexp.union` does produce a shareable object.

```irb
irb(main):001> a = /a/
=> /a/
irb(main):002> b = Regexp.union(a)
=> /a/
irb(main):003> c = Regexp.union(a, a)
=> /(?-mix:a)|(?-mix:a)/
irb(main):004> Ractor.shareable?(a)
=> true
irb(main):005> Ractor.shareable?(b)
=> true
irb(main):006> Ractor.shareable?(c)
=> false
```





-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:123143] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
  2025-08-31  2:54 [ruby-core:123141] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible) niku (niku _) via ruby-core
  2025-08-31  4:25 ` [ruby-core:123142] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2025-08-31  4:42 ` nobu (Nobuyoshi Nakada) via ruby-core
  2025-08-31  6:42 ` [ruby-core:123144] " niku (niku _) via ruby-core
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-08-31  4:42 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21558 has been updated by nobu (Nobuyoshi Nakada).


Another example is `Range`.
All instances of `Range` are automatically frozen so they are Ractor-shareable.
Personally, I think freezing all `Regexp` instances also may be nice, but that's a different story than `Regexp.union`.

----------------------------------------
Bug #21558: Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
https://bugs.ruby-lang.org/issues/21558#change-114476

* Author: niku (niku _)
* Status: Feedback
* ruby -v: ruby 3.5.0dev (2025-08-30T18:24:25Z master 5c7dfe85a1) +PRISM [arm64-darwin24]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Regexp.union returns a non-shareable object when given multiple Regex arguments. Is this expected behavior?
It would be preferable if the resulting Regexp were shareable, since single-argument `Regexp.union` does produce a shareable object.

```irb
irb(main):001> a = /a/
=> /a/
irb(main):002> b = Regexp.union(a)
=> /a/
irb(main):003> c = Regexp.union(a, a)
=> /(?-mix:a)|(?-mix:a)/
irb(main):004> Ractor.shareable?(a)
=> true
irb(main):005> Ractor.shareable?(b)
=> true
irb(main):006> Ractor.shareable?(c)
=> false
```





-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:123144] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
  2025-08-31  2:54 [ruby-core:123141] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible) niku (niku _) via ruby-core
  2025-08-31  4:25 ` [ruby-core:123142] " nobu (Nobuyoshi Nakada) via ruby-core
  2025-08-31  4:42 ` [ruby-core:123143] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2025-08-31  6:42 ` niku (niku _) via ruby-core
  2025-08-31  6:55 ` [ruby-core:123145] " niku (niku _) via ruby-core
  2025-09-01 18:38 ` [ruby-core:123159] " Eregon (Benoit Daloze) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: niku (niku _) via ruby-core @ 2025-08-31  6:42 UTC (permalink / raw)
  To: ruby-core; +Cc: niku (niku _)

Issue #21558 has been updated by niku (niku _).


> Regexp.union creates a new instance, except for a single Regexp argument case.

Ah, that makes perfect sense now. Thank you for the detailed explanation.

```irb
irb(main):001> a = /a/
=> /a/
irb(main):002> a.__id__
=> 7232
irb(main):003> b = Regexp.union(a)
=> /a/
irb(main):004> b.__id__
=> 7232
irb(main):005> c = Regexp.union(a, a)
=> /(?-mix:a)|(?-mix:a)/
irb(main):006> c.__id__
=> 17912
```

> Personally, I think freezing all Regexp instances also may be nice, but that's a different story than Regexp.union.

I agree with your opinion. I'll create a new issue.

----------------------------------------
Bug #21558: Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
https://bugs.ruby-lang.org/issues/21558#change-114477

* Author: niku (niku _)
* Status: Feedback
* ruby -v: ruby 3.5.0dev (2025-08-30T18:24:25Z master 5c7dfe85a1) +PRISM [arm64-darwin24]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Regexp.union returns a non-shareable object when given multiple Regex arguments. Is this expected behavior?
It would be preferable if the resulting Regexp were shareable, since single-argument `Regexp.union` does produce a shareable object.

```irb
irb(main):001> a = /a/
=> /a/
irb(main):002> b = Regexp.union(a)
=> /a/
irb(main):003> c = Regexp.union(a, a)
=> /(?-mix:a)|(?-mix:a)/
irb(main):004> Ractor.shareable?(a)
=> true
irb(main):005> Ractor.shareable?(b)
=> true
irb(main):006> Ractor.shareable?(c)
=> false
```





-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:123145] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
  2025-08-31  2:54 [ruby-core:123141] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible) niku (niku _) via ruby-core
                   ` (2 preceding siblings ...)
  2025-08-31  6:42 ` [ruby-core:123144] " niku (niku _) via ruby-core
@ 2025-08-31  6:55 ` niku (niku _) via ruby-core
  2025-09-01 18:38 ` [ruby-core:123159] " Eregon (Benoit Daloze) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: niku (niku _) via ruby-core @ 2025-08-31  6:55 UTC (permalink / raw)
  To: ruby-core; +Cc: niku (niku _)

Issue #21558 has been updated by niku (niku _).


I've found an issue that already talked about it https://bugs.ruby-lang.org/issues/17256.

----------------------------------------
Bug #21558: Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
https://bugs.ruby-lang.org/issues/21558#change-114478

* Author: niku (niku _)
* Status: Feedback
* ruby -v: ruby 3.5.0dev (2025-08-30T18:24:25Z master 5c7dfe85a1) +PRISM [arm64-darwin24]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Regexp.union returns a non-shareable object when given multiple Regex arguments. Is this expected behavior?
It would be preferable if the resulting Regexp were shareable, since single-argument `Regexp.union` does produce a shareable object.

```irb
irb(main):001> a = /a/
=> /a/
irb(main):002> b = Regexp.union(a)
=> /a/
irb(main):003> c = Regexp.union(a, a)
=> /(?-mix:a)|(?-mix:a)/
irb(main):004> Ractor.shareable?(a)
=> true
irb(main):005> Ractor.shareable?(b)
=> true
irb(main):006> Ractor.shareable?(c)
=> false
```





-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:123159] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
  2025-08-31  2:54 [ruby-core:123141] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible) niku (niku _) via ruby-core
                   ` (3 preceding siblings ...)
  2025-08-31  6:55 ` [ruby-core:123145] " niku (niku _) via ruby-core
@ 2025-09-01 18:38 ` Eregon (Benoit Daloze) via ruby-core
  4 siblings, 0 replies; 6+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2025-09-01 18:38 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #21558 has been updated by Eregon (Benoit Daloze).


There is also #8948. I didn't get time to try it, but anyone is welcome to try and find if there are any failures in CI/the test suites and if so how to fix them.

----------------------------------------
Bug #21558: Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible)
https://bugs.ruby-lang.org/issues/21558#change-114495

* Author: niku (niku _)
* Status: Feedback
* ruby -v: ruby 3.5.0dev (2025-08-30T18:24:25Z master 5c7dfe85a1) +PRISM [arm64-darwin24]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Regexp.union returns a non-shareable object when given multiple Regex arguments. Is this expected behavior?
It would be preferable if the resulting Regexp were shareable, since single-argument `Regexp.union` does produce a shareable object.

```irb
irb(main):001> a = /a/
=> /a/
irb(main):002> b = Regexp.union(a)
=> /a/
irb(main):003> c = Regexp.union(a, a)
=> /(?-mix:a)|(?-mix:a)/
irb(main):004> Ractor.shareable?(a)
=> true
irb(main):005> Ractor.shareable?(b)
=> true
irb(main):006> Ractor.shareable?(c)
=> false
```





-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-09-01 18:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-31  2:54 [ruby-core:123141] [Ruby Bug#21558] Regexp.union with multiple regexps returns a non-shareable object (should be shareable if possible) niku (niku _) via ruby-core
2025-08-31  4:25 ` [ruby-core:123142] " nobu (Nobuyoshi Nakada) via ruby-core
2025-08-31  4:42 ` [ruby-core:123143] " nobu (Nobuyoshi Nakada) via ruby-core
2025-08-31  6:42 ` [ruby-core:123144] " niku (niku _) via ruby-core
2025-08-31  6:55 ` [ruby-core:123145] " niku (niku _) via ruby-core
2025-09-01 18:38 ` [ruby-core:123159] " Eregon (Benoit Daloze) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).