From: merch-redmine@... Date: 2020-05-26T02:57:10+00:00 Subject: [ruby-core:98517] [Ruby master Bug#16906] Calling Thread#thread_variable? in IRB sometimes produce wrong result Issue #16906 has been updated by jeremyevans0 (Jeremy Evans). That approach didn't work as there are tests for inadvertent symbol creation. To fix that, we need to force ID creation in thread_local_set. I've updated the pull request to use that approach, and made thread_variable_get use the same inadvertent symbol creation check as thread_variable?. ---------------------------------------- Bug #16906: Calling Thread#thread_variable? in IRB sometimes produce wrong result https://bugs.ruby-lang.org/issues/16906#change-85793 * Author: tyok (Mohammad Satrio) * Status: Open * Priority: Normal * ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin17] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Consider this script: ``` ruby Thread.current.thread_variable_set("ab", 12) puts Thread.current.thread_variable?("ab") puts Thread.current.thread_variable?(:ab) puts Thread.current.thread_variable?("ab") ``` When I put the script above in a file and run it, I got three `true` as expected: ``` bash-3.2$ ruby test.rb true true true ``` But when I copy each line to IRB, I got false on the first check: ``` shell bash-3.2$ irb irb(main):001:0> Thread.current.thread_variable_set("ab", 12) => 12 irb(main):002:0> puts Thread.current.thread_variable?("ab") false => nil irb(main):003:0> puts Thread.current.thread_variable?(:ab) true => nil irb(main):004:0> puts Thread.current.thread_variable?("ab") true => nil ``` I expect it to print three `true` in IRB, just like when I run the script via file. ---Files-------------------------------- test.rb (173 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: