[#104004] [Ruby master Feature#17883] Load bundler/setup earlier to make `bundle exec ruby -r` respect Gemfile — mame@...
Issue #17883 has been reported by mame (Yusuke Endoh).
21 messages
2021/05/24
[ruby-core:103791] [Ruby master Bug#17857] `when 0r` and `when 0i` do not match with `case 0`
From:
mame@...
Date:
2021-05-12 05:05:42 UTC
List:
ruby-core #103791
Issue #17857 has been reported by mame (Yusuke Endoh). ---------------------------------------- Bug #17857: `when 0r` and `when 0i` do not match with `case 0` https://bugs.ruby-lang.org/issues/17857 * Author: mame (Yusuke Endoh) * Status: Open * Priority: Normal * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- The following code prints `:bar` between Ruby 2.1 .. 2.5, and dumps core since Ruby 2.6. ``` case 0 when 0r p :foo else p :bar #=> :bar end ``` A Complex has the same issue. ``` case 0 when 0i p :foo else p :bar #=> :bar end ``` The segfault issue was fixed by #17854. So the current master it prints `:bar`. However, I believe it should print `:foo` because `0r === 0` evaluates to true. This weird behavior is caused by the optimization which uses a hidden hash to dispatch to when clauses. By disabling the optimization, the code prints `:foo`. ``` opt = RubyVM::InstructionSequence.compile_option opt[:specialized_instruction] = false RubyVM::InstructionSequence.compile(<<END, **opt).eval case 0 when 0r p :foo #=> :foo else p :bar end END ``` I think the optimization should be disabled when T_RATIONAL or T_COMPLEX are used. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>