Issue #22007 has been updated by matz (Yukihiro Matsumoto). Status changed from Open to Closed The current behavior follows from lazy evaluation of rescue clauses, which is intentional. As @kddnewton noted in #note-7, the arguments are expressions and can't be classified statically, so an eager check means evaluating them all, with overhead and side effects. Generalizing to `===` on arbitrary expressions is consistent with case/when, but it removes a check that catches real mistakes. The `Minitest` case in #note-4 is exactly that: a regexp silently never matching. I'd rather keep the `TypeError`. For `assert_raises`, I agree with #note-6 that Minitest can handle non-Module arguments itself. I will keep the current behavior as is. Matz. ---------------------------------------- Bug #22007: Inconsistent type checking on rescue https://bugs.ruby-lang.org/issues/22007#change-117323 * Author: zenspider (Ryan Davis) * Status: Closed * ruby -v: 4.0.2 * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- this works fine (but I don't think it should): ```ruby begin raise "nope" rescue RuntimeError, /why am I allowed?/, "or me?" => e # yay end ``` whereas this version shows a type error, which seems right: ```ruby begin begin raise "nope" rescue /why am I NOT allowed/, "if I was allowed before?" => e p e end rescue TypeError => te p te end ``` I think all the args on rescue should be checked to be `Module` -- https://bugs.ruby-lang.org/