
Issue #20978 has been reported by zverok (Victor Shepelev). ---------------------------------------- Bug #20978: Ractor[]/Thread[]/Fiber[] behavior difference https://bugs.ruby-lang.org/issues/20978 * Author: zverok (Victor Shepelev) * Status: Open * ruby -v: ruby 3.4.0dev (2024-12-22T06:08:19Z master 3808d29e20) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- `Ractor.[]` and `.[]=` support string and symbol keys (treating them by string value, and also accepting anything responding to `#to_str`): ```ruby Ractor[:value] = 10 Ractor[:value] #=> 10 Ractor['value'] #=> 10 o = Object.new def o.to_str = 'value' Ractor[o] #=> 10 Ractor[1] # in 'Ractor.[]': 1 is not a symbol nor a string (TypeError) ``` But `Fiber.[]` only accept symbols: ```ruby Fiber[:value] = 10 Fiber['value'] # in 'Fiber.[]': wrong argument type String (expected Symbol) (TypeError) ``` `Thread#[]` and `#[]=` behave like Ractor’s. (The documentation for Fiber and Thread follows the reality—while Ractor’s current docs don’t specify key type at all—but the discrepancy feels somewhat weird.) -- https://bugs.ruby-lang.org/