From: "byroot (Jean Boussier) via ruby-core" Date: 2024-05-13T02:26:43+00:00 Subject: [ruby-core:117851] [Ruby master Feature#20484] A new pragma for eager resolution of classes referenced in rescue clauses. Issue #20484 has been updated by byroot (Jean Boussier). Eager resolution of referenced constants at parse time would be very painful in many case as it would add some extra constraints on load order, likely causing circular dependency issues, even before considering things such as `autoload`. Ultimately I think this sort of errors is better handled by static analysis. For instance this type of error is caught by sorbet by default without needing any type annotations. I don't know if `steep` does too, but I suspect it can. I'm also not fond of the idea of adding new pragmas, if anything I'd prefer if we eliminated some. ---------------------------------------- Feature #20484: A new pragma for eager resolution of classes referenced in rescue clauses. https://bugs.ruby-lang.org/issues/20484#change-108259 * Author: jfrisby (Jon Frisby) * Status: Feedback ---------------------------------------- I've been using Ruby for 20 years, and just today learned (the hard way) that the class name(s) referenced in a `rescue` clause are not resolved until an exception occurs. Upon reflection, this behavior probably makes sense in a lot of situations. Late resolution may simplify code loading for the developer. I would, however, love to see an opt-in feature (a la `frozen-string-literal`) to force resolution when the code is loaded/parsed. -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/