[#111472] [Ruby master Bug#19274] Error installing ruby 3.2.0 on RH 8 — "aalllop (Alberto Allegue) via ruby-core" <ruby-core@...>
Issue #19274 has been reported by aalllop (Alberto Allegue).
5 messages
2022/12/28
[#111508] Data support for versions before 3.2.0 — Eustáquio Rangel via ruby-core <ruby-core@...>
I was wondering that every piece of code (gems, etc) that use the new Data =
3 messages
2022/12/29
[ruby-core:111347] [Ruby master Feature#19245] Strict mode for Array#pack that doesn't silently truncate numbers that are too large for the given directive
From:
"byroot (Jean Boussier) via ruby-core" <ruby-core@...>
Date:
2022-12-20 12:30:55 UTC
List:
ruby-core #111347
Issue #19245 has been updated by byroot (Jean Boussier).
Interesting that the `setbyte` conclusion was to implicitly modulo.
Whereas `Integer#chr` does raise `RangeError`:
```ruby
>> 256.chr
in `chr': 256 out of char range (RangeError)
```
----------------------------------------
Feature #19245: Strict mode for Array#pack that doesn't silently truncate numbers that are too large for the given directive
https://bugs.ruby-lang.org/issues/19245#change-100721
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
```ruby
>> [256].pack("C").unpack1("C")
=> 0
>> [257].pack("C").unpack1("C")
=> 1
```
This is specified:
```ruby
it "encodes the least significant 32 bits of a negative number" do
[ [[-0x0000_0021], "\xdf\xff\xff\xff"],
[[-0x0000_4321], "\xdf\xbc\xff\xff"],
[[-0x0065_4321], "\xdf\xbc\x9a\xff"],
[[-0x7865_4321], "\xdf\xbc\x9a\x87"]
].should be_computed_by(:pack, pack_format())
end
```
But not documented in `Array#pack`.
I think that in many case this may lead to silent bugs.
### Possible solutions
We could have a strict version of `pack`, either `pack(template, strict: true)` or `pack!(template)`.
Or alternatively if we think this is never a desired behavior, we could change `pack` to first warn on truncation and later raise.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/