From: "Eregon (Benoit Daloze) via ruby-core" Date: 2026-04-17T23:28:04+00:00 Subject: [ruby-core:125318] [Ruby Bug#22007] Inconsistent type checking on rescue Issue #22007 has been updated by Eregon (Benoit Daloze). zenspider (Ryan Davis) wrote in #note-5: > so what should `rescue /regexp/` do? It would do `/regexp/ === exception`, which is not useful but consistent. The `assert_raises` example is interesting, I recall https://github.com/test-unit/test-unit/issues/347. Maybe Minitest could have the intuitive semantics so that `assert_raises` when it sees a non-Module matches that against the exception message? ---------------------------------------- Bug #22007: Inconsistent type checking on rescue https://bugs.ruby-lang.org/issues/22007#change-117071 * Author: zenspider (Ryan Davis) * Status: Open * 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/