[#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:111426] [Ruby master Bug#19257] Data that defines a member called hash
From:
"ufuk (Ufuk Kayserilioglu) via ruby-core" <ruby-core@...>
Date:
2022-12-25 18:02:54 UTC
List:
ruby-core #111426
Issue #19257 has been updated by ufuk (Ufuk Kayserilioglu). While I understand the potential for confusion or a foot-gun, I also agree with @nobu that this is in spirit with how Ruby operates, where anything is overridable. `Struct` has been behaving in the exact same way for years: ```ruby irb(main):001:0> Foo = Struct.new(:hash) => Foo irb(main):002:0> Foo.new(42).hash => 42 irb(main):003:0> Bar = Struct.new(:bar) => Bar irb(main):004:0> Bar.new(42).hash => 4004416633903135689 ``` Having said that, if the proposal was to add a warning for when users override some special methods, like `hash` or `object_id` or something, then I would be all for that. A warning for these situations is good enough to warn people who might be doing this by mistake, but is not as drastic as an error preventing them from doing it. ---------------------------------------- Bug #19257: Data that defines a member called hash https://bugs.ruby-lang.org/issues/19257#change-100798 * Author: solnic (Peter Solnica) * Status: Feedback * Priority: Normal * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-darwin22] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- I believe this should raise an error given that `Data#hash` exists as a pre-defined core method and serves a very specific purpose: ``` ruby data = Data.define(:hash) obj = data.new(hash: "foo") obj.hash # => "foo" ``` An alternative would be to make `obj[:hash]` return the value of the member and `obj.hash` would return the hash of the object, but that could be confusing. -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/