Issue #20043 has been reported by tenderlovemaking (Aaron Patterson).
----------------------------------------
Bug #20043: `defined?` checks for method existence but only sometimes
https://bugs.ruby-lang.org/issues/20043
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-12-05T21:25:34Z master 56eccb350b) [arm64-darwin23]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
When an expression is passed to `defined?`, it will _sometimes_ check if a method in a sub-expression is defined and sometimes it won't.
For example:
```
$ ./miniruby -e'p defined?(a)'
nil
$ ./miniruby -e'p defined?([a])'
nil
```
In the above case, Ruby will check whether or not the method `a` is defined, and it returns `nil`. However, if you use a splat, it will not check:
```
$ ./miniruby -e'p defined?([*a])'
"expression"
```
The same thing seems to happen with method parameters:
```
$ ./miniruby -e'p defined?(itself)'
"method"
$ ./miniruby -e'p defined?(itself(a))'
nil
$ ./miniruby -e'p defined?(itself(*a))'
"method"
```
Oddly, `defined?` will check contents of arrays, but _won't_ check contents of hashes:
```
$ ./miniruby -e'p defined?([[[[a]]]])'
nil
$ ./miniruby -e'p defined?({ a => a })'
"expression"
```
I think all of the cases that refer to `a` should check whether or not `a` is defined regardless of splats or hashes.
--
https://bugs.ruby-lang.org/
Issue #19365 has been reported by luke-gru (Luke Gruber).
----------------------------------------
Bug #19365: Ractors can access non-shareable values through enumerators
https://bugs.ruby-lang.org/issues/19365
* Author: luke-gru (Luke Gruber)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
I don't think enumerators should be able to be passed to `Ractor.new`
```ruby
obj = Object.new # unshareable value
p obj
Ractor.new([obj].each) {|f| p f.first }.take
```
--
https://bugs.ruby-lang.org/
Issue #19395 has been reported by luke-gru (Luke Gruber).
----------------------------------------
Bug #19395: Process forking within non-main Ractor creates child stuck in busy loop
https://bugs.ruby-lang.org/issues/19395
* Author: luke-gru (Luke Gruber)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
```ruby
def test_fork_in_ractor
r2 = Ractor.new do
pid = fork do
exit Ractor.count
end
pid
end
pid = r2.take
puts "Process #{Process.pid} waiting for #{pid}"
_pid, status = Process.waitpid2(pid) # stuck forever
if status.exitstatus != 1
raise "status is #{status.exitstatus}"
end
end
test_fork_in_ractor()
```
$ top # shows CPU usage is high for child process
--
https://bugs.ruby-lang.org/
Issue #19408 has been reported by luke-gru (Luke Gruber).
----------------------------------------
Bug #19408: Object no longer frozen after moved from a ractor
https://bugs.ruby-lang.org/issues/19408
* Author: luke-gru (Luke Gruber)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
I think frozen objects should still be frozen after a move.
```ruby
r = Ractor.new do
obj = receive
p obj.frozen? # should be true but is false
p obj
end
obj = [Object.new].freeze
r.send(obj, move: true)
r.take
```
--
https://bugs.ruby-lang.org/
Issue #20080 has been reported by stuyam (Stuart Yamartino).
----------------------------------------
Feature #20080: Implement #begin_and_end method on Range
https://bugs.ruby-lang.org/issues/20080
* Author: stuyam (Stuart Yamartino)
* Status: Open
* Priority: Normal
----------------------------------------
Followup Reference: #20027
This feature request is to implement a method called `#begin_and_end` on `Range` that returns an array of the first and last value stored in a range:
```ruby
(1..300).begin_and_end #=> [1, 300]
first, last = (300..1).begin_and_end
first #=> 300
last #=> 1
```
I believe this would be a great addition to Ranges as they are often used to pass around a single object used to hold endpoints, and this allows easier retrieval of those endpoints.
This would allow easier deconstruction into start and end values using array deconstruction as well as a simpler way to serialize to a more primitive object such as an array for database storage.
This implementation was suggested by @mame in my initial feature suggestion regarding range deconstruction: https://bugs.ruby-lang.org/issues/20027
This implementation would work similar to how `#minmax` works where it returns an array of two numbers, however the difference is that `#minmax` doesn't work with reverse ranges as @Dan0042 pointed out in the link above:
```ruby
(1..42).minmax #=> [1, 42]
(42..1).minmax #=> [nil, nil]
```
--
https://bugs.ruby-lang.org/
Issue #20210 has been reported by kddnewton (Kevin Newton).
----------------------------------------
Misc #20210: Invalid source encoding raises ArgumentError, not SyntaxError
https://bugs.ruby-lang.org/issues/20210
* Author: kddnewton (Kevin Newton)
* Status: Open
* Priority: Normal
----------------------------------------
I was hoping we could change the error that is raised when an invalid source encoding is found from an ArgumentError to a SyntaxError.
First let me say, if this isn't possible for backward compatibility, I understand. Please do not take this as me not caring about backward compatibility.
Right now, if you have the script `# encoding: foo\n"bar"`, it will raise an ArgumentError, not a SyntaxError. If there are other syntax errors in the file, there's no way to concat them together to give feedback to the user. If a user wants to consistently handle the errors coming back from a parse, they currently have to rescue ArgumentError and SyntaxError.
Ideally it would all be SyntaxError, so we could handle them consistently and append all errors together.
--
https://bugs.ruby-lang.org/