[ruby-core:118431] [Ruby master Bug#20606] Thread#thread_variable_get, Thread#thread_variable? and Thread#[] methods handle non-String/Symbol parameter values differently
From:
"andrykonchin (Andrew Konchin) via ruby-core" <ruby-core@...>
Date:
2024-07-03 15:56:54 UTC
List:
ruby-core #118431
Issue #20606 has been reported by andrykonchin (Andrew Konchin).
----------------------------------------
Bug #20606: Thread#thread_variable_get, Thread#thread_variable? and Thread#[] methods handle non-String/Symbol parameter values differently
https://bugs.ruby-lang.org/issues/20606
* Author: andrykonchin (Andrew Konchin)
* Status: Open
* ruby -v: 3.2.4
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
The `Thread#thread_variable_get`, `Thread#thread_variable?` and `Thread#[]` methods handle the `key` parameter that is not a String or a Symbol in different way but I would expect them to be consistent.
When no thread-local variables were assigned to a thread the `Thread#thread_variable_get` and `Thread#thread_variable?` methods don't raise `TypeError` when argument is of incorrect type. But `Thread#[]` does raise `TypeError` exception:
```ruby
t = Thread.new {}.join
puts t.thread_variable_get(123).inspect # nil
puts t.thread_variable?(123).inspect # false
t[123] # `[]': 123 is not a symbol nor a string (TypeError)
```
--
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/lists/ruby-core.ml.ruby-lang.org/