Issue #19260 has been reported by hsbt (Hiroshi SHIBATA).
----------------------------------------
Bug #19260: ruby/spec is failed with Ruby 3.3
https://bugs.ruby-lang.org/issues/19260
* Author: hsbt (Hiroshi SHIBATA)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
After bumping version, we got the some fails with ruby/spec.
https://github.com/ruby/ruby/actions/runs/3778576412/jobs/6423166914
```
1)
Literal Regexps handles a lookbehind with ss characters ERROR
RegexpError: invalid pattern in look-behind: /(?<!dss)/i
/home/runner/work/ruby/ruby/src/spec/ruby/language/regexp_spec.rb:120:in `block (3 levels) in <top (required)>'
/home/runner/work/ruby/ruby/src/spec/ruby/language/regexp_spec.rb:4:in `<top (required)>'
2)
Float#round does not lose precision during the rounding process FAILED
Expected 767573.18758 to have same value and type as 767573.18759
/home/runner/work/ruby/ruby/src/spec/ruby/core/float/round_spec.rb:148:in `block (3 levels) in <top (required)>'
/home/runner/work/ruby/ruby/src/spec/ruby/core/float/round_spec.rb:3:in `<top (required)>'
3)
Encoding#replicate has been removed FAILED
Expected #<Encoding:US-ASCII>.respond_to? :replicate, true
to be falsy but was true
/home/runner/work/ruby/ruby/src/spec/ruby/core/encoding/replicate_spec.rb:72:in `block (3 levels) in <top (required)>'
/home/runner/work/ruby/ruby/src/spec/ruby/core/encoding/replicate_spec.rb:4:in `<top (required)>'
```
--
https://bugs.ruby-lang.org/
Issue #19275 has been reported by xtkoba (Tee KOBAYASHI).
----------------------------------------
Bug #19275: Bundled gems extensions are not installed with 3.2.0 release tarball
https://bugs.ruby-lang.org/issues/19275
* Author: xtkoba (Tee KOBAYASHI)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [aarch64-linux-android]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
Bundled gems extensions are not installed with 3.2.0 release tarball when cross building for `aarch64-linux-android` target.
Possibly related to #19271.
Excerpt from build log:
```
2022-12-28T12:39:39.5065133Z linking shared-object rbs_extension.so
2022-12-28T12:39:39.5317220Z Successfully remade target file '../../../../../.bundle/extensions/aarch64-linux-android/3.2.0/rbs-2.8.2/rbs_extension.so'.
[...]
2022-12-28T12:40:06.9333744Z rm -rf .bundle/extensions/aarch64-linux-android/
```
Seems like bundled gems extensions are built but removed afterwards.
The workaround we took is to patch `common.mk` so that `outdate-bundled-gems` is not triggered:
```patch
--- a/common.mk
+++ b/common.mk
@@ -1375,7 +1375,6 @@
refresh-gems: update-bundled_gems prepare-gems
prepare-gems: $(HAVE_BASERUBY:yes=update-gems) $(HAVE_BASERUBY:yes=extract-gems)
-prepare-gems: $(DOT_WAIT) $(HAVE_BASERUBY:yes=outdate-bundled-gems)
extract-gems: $(HAVE_BASERUBY:yes=update-gems)
update-gems$(gnumake:yes=-sequential): PHONY
```
Full build log is attached.
---Files--------------------------------
build.log.xz (245 KB)
--
https://bugs.ruby-lang.org/
Issue #19150 has been reported by Eregon (Benoit Daloze).
----------------------------------------
Bug #19150: pack/unpack silently ignores unknown directives
https://bugs.ruby-lang.org/issues/19150
* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
But I believe it should be an error instead.
Typically when a parser sees a syntax error it should fail not continue silently.
For instance `[1].pack('<L')` succeeds and only emits a warning if `$VERBOSE` is true.
This behavior caused confusion in https://github.com/oracle/truffleruby/issues/2791
I think it should fail with an `ArgumentError` instead.
Extracted from https://bugs.ruby-lang.org/issues/19108#note-3
--
https://bugs.ruby-lang.org/
Issue #19269 has been reported by andrykonchin (Andrew Konchin).
----------------------------------------
Bug #19269: Constant lookup and #instance_eval
https://bugs.ruby-lang.org/issues/19269
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
* ruby -v: 3.1.3
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
I've noticed a confusing behaviour of `#instance_eval` (and `#instance_exec` as well). In some cases it doesn't see constants defined in the object class.
Examples:
```ruby
C = 1
class A
C = 2
end
```
When `#instance_eval` is called with a String - `A::C` constant is visible, that is pretty expected:
```ruby
A.new.instance_eval("C") # => 2
```
But when it's called with a block - `A::C` isn't visible:
```ruby
A.new.instance_eval { C } # => 1
```
If we define a method that returns a constant (defined in the class), then `A::C` is visible in both cases:
```ruby
C = 1
class A
C = 2
def c; C; end
end
A.new.instance_eval("c") # => 2
A.new.instance_eval { c } # => 2
```
So we see that when `#instance_eval` called with a block and a constant is assessed directly is the only case when a class constant isn't visible.
Wondering whether it's an expected behaviour and the reason to behave this way.
--
https://bugs.ruby-lang.org/
Issue #19270 has been reported by andrykonchin (Andrew Konchin).
----------------------------------------
Bug #19270: Constants lookup and a singleton class issue
https://bugs.ruby-lang.org/issues/19270
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* Priority: Normal
* ruby -v: 3.1.3
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
I've noticed that a constant declared in a singleton class may be not visible on an object:
```ruby
class A
def c; C; end
end
a = A.new
klass = (class << a; self; end)
klass.const_set(:C, 1)
a.c
# (irb):2:in `c': uninitialized constant A::C (NameError)
```
I would expect that such constant is visible and accessible on an object. It is expected and intentional behaviour?
--
https://bugs.ruby-lang.org/
Issue #19244 has been reported by larskanis (Lars Kanis).
----------------------------------------
Bug #19244: Windows: USERPROFILE should be preferred over HOMEPATH
https://bugs.ruby-lang.org/issues/19244
* Author: larskanis (Lars Kanis)
* 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
----------------------------------------
Create a new local user on Windows called "testuser".
Then switch to the new user per runas:
```
C:\> runas /user:testuser cmd
```
Then in the new window:
```
C:\>ruby -e "p Dir.home"
"C:/WINDOWS/system32"
C:\>echo %HOMEDRIVE%
C:
C:\>echo %HOMEPATH%
\WINDOWS\system32
C:\>echo %USERPROFILE%
C:\Users\testuser
```
`Dir.home` should return the home directory of the user.
Instead it returns `C:/WINDOWS/system32`.
HOMEPATH is set to "\WINDOWS\system32" when running per "runas" session.
This directory is not writable by ordinary users, leading to errors with many ruby tools.
Also config files in the home directory are not recognized.
All versions of ruby until current master branch are affected.
--
https://bugs.ruby-lang.org/
Issue #19285 has been reported by zzak (Zak Scott).
----------------------------------------
Bug #19285: (docs.rlo) Split stdlib and core documents
https://bugs.ruby-lang.org/issues/19285
* Author: zzak (Zak Scott)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
It seems we merge all of the docs for stdlib and core into one for docs.ruby-lang.org, this creates weirdness like [Kernel](https://docs.ruby-lang.org/en/master/Kernel.html) which includes monkey patches for rubygems for example.
> RubyGems adds the gem method to allow activation of specific gem versions and overrides the require method on Kernel to make gems appear as if they live on the $LOAD_PATH. See the documentation of these methods for further detail.
--
https://bugs.ruby-lang.org/
Issue #16986 has been updated by matz (Yukihiro Matsumoto).
If I have to pick one from either Struct or Data, I'd pick Data. But still don't like the notation proposed.
Matz.
----------------------------------------
Feature #16986: Anonymous Struct literal
https://bugs.ruby-lang.org/issues/16986#change-100913
* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
# Abstract
How about introducing anonymous Struct literal such as `${a: 1, b: 2}`?
It is almost the same as `Struct.new(:a, :b).new(1, 2)`.
# Proposal
## Background
In many cases, people use hash objects to represent a set of values such as `person = {name: "ko1", country: 'Japan'}` and access its values through `person[:name]` and so on. It is not easy to write (three characters `[:]`!), and it easily introduces misspelling (`person[:nama]` doesn't raise an error).
If we make a `Struct` object by doing `Person = Struct.new(:name, :age)` and `person = Person.new('ko1', 'Japan')`, we can access its values through `person.name` naturally. However, it costs coding. And in some cases, we don't want to name the class (such as `Person`).
Using `OpenStruct` (`person = OpenStruct.new(name: "ko1", country: "Japan")`), we can access it through `person.name`, but we can extend the fields unintentionally, and the performance is not good.
Of course, we can define a class `Person` with attr_readers. But it takes several lines.
To summarize the needs:
* Easy to write
* Doesn't require declaring the class
* Accessible through `person.name` format
* Limited fields
* Better performance
## Idea
Introduce new literal syntax for an anonymous Struct such as: `${ a: 1, b: 2 }`.
Similar to Hash syntax (with labels), but with `$` prefix to distinguish.
Anonymous structs which have the same member in the same order share their class.
```ruby
s1 = ${a: 1, b: 2, c: 3}
s2 = ${a: 1, b: 2, c: 3}
assert s1 == s2
s3 = ${a: 1, c: 3, b: 2}
s4 = ${d: 4}
assert_equal false, s1 == s3
assert_equal false, s1 == s4
```
## Note
Unlike Hash literal syntax, this proposal only allows `label: expr` notation. No `${**h}` syntax.
This is because if we allow to splat a Hash, it can be a vulnerability by splatting outer-input Hash.
Thanks to this spec, we can specify anonymous Struct classes at compile time.
We don't need to find or create Struct classes at runtime.
## Implementatation
https://github.com/ruby/ruby/pull/3259
# Discussion
## Notation
Matz said he thought about `{|a: 1, b: 2 |}` syntax.
## Performance
Surprisingly, Hash is fast and Struct is slow.
```ruby
Benchmark.driver do |r|
r.prelude <<~PRELUDE
st = Struct.new(:a, :b).new(1, 2)
hs = {a: 1, b: 2}
class C
attr_reader :a, :b
def initialize() = (@a = 1; @b = 2)
end
ob = C.new
PRELUDE
r.report "ob.a"
r.report "hs[:a]"
r.report "st.a"
end
__END__
Warming up --------------------------------------
ob.a 38.100M i/s - 38.142M times in 1.001101s (26.25ns/i, 76clocks/i)
hs[:a] 37.845M i/s - 38.037M times in 1.005051s (26.42ns/i, 76clocks/i)
st.a 33.348M i/s - 33.612M times in 1.007904s (29.99ns/i, 87clocks/i)
Calculating -------------------------------------
ob.a 87.917M i/s - 114.300M times in 1.300085s (11.37ns/i, 33clocks/i)
hs[:a] 85.504M i/s - 113.536M times in 1.327850s (11.70ns/i, 33clocks/i)
st.a 61.337M i/s - 100.045M times in 1.631064s (16.30ns/i, 47clocks/i)
Comparison:
ob.a: 87917391.4 i/s
hs[:a]: 85503703.6 i/s - 1.03x slower
st.a: 61337463.3 i/s - 1.43x slower
```
I believe we can speed up `Struct` similarly to ivar accesses, so we can improve the performance.
BTW, OpenStruct (os.a) is slow.
```
Comparison:
hs[:a]: 92835317.7 i/s
ob.a: 85865849.5 i/s - 1.08x slower
st.a: 53480417.5 i/s - 1.74x slower
os.a: 12541267.7 i/s - 7.40x slower
```
For memory consumption, `Struct` is more lightweight because we don't need to keep the key names.
## Naming
If we name an anonymous class, literals with the same members share the name.
```ruby
s1 = ${a:1}
s2 = ${a:2}
p [s1, s2] #=> [#<struct a=1>, #<struct a=2>]
A = s1.class
p [s1, s2] #=> [#<struct A a=1>, #<struct A a=2>]
```
Maybe that is not a good behavior.
--
https://bugs.ruby-lang.org/