
Issue #20026 has been updated by nobu (Nobuyoshi Nakada). You may want to write: ```ruby begin raise FooError rescue FooError, BarError => e puts "rescued #{e.class}" end ``` ---------------------------------------- Bug #20026: Ruby doesn't throw a syntax error when rescuing with || https://bugs.ruby-lang.org/issues/20026#change-105462 * Author: arian (Arian Faurtosh) * Status: Rejected * Priority: Normal * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin23] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- We had a coworker new to ruby try an interesting syntax for rescue that doesn't result in a syntax error, and works partially. Why does ruby allow the logical OR || operator, is there a purpose for this? If not this feels like it should be a syntax error, instead of resulting in partially working code. ``` ruby class FooError < StandardError; end class BarError < StandardError; end # works begin raise FooError rescue FooError || BarError => e puts "rescued #{e.class}" end # doesn't work begin raise FooError rescue FooError || BarError => e puts "rescued #{e.class}" end ``` -- https://bugs.ruby-lang.org/