Project

General

Profile

Bug #20606

Updated by andrykonchin (Andrew Konchin) 5 months ago

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 and raise an exception. 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) 
 ```

Back