[ruby-core:94822] [Ruby master Bug#12984] `rescue *[]` should be equivalent to `rescue` as `method_call(*[])` is equivalent to `method_call`
From:
eregontp@...
Date:
2019-09-07 10:06:33 UTC
List:
ruby-core #94822
Issue #12984 has been updated by Eregon (Benoit Daloze). The core of this is that `rescue` (which means rescue StandardError) vs `rescue *classes` (which means rescue any of `classes`) is detected at parse time, not at runtime. I think the current logic makes sense in that regard, and I think it's is less surprising than `rescue *no_classes` to "magically" rescue `StandardError`. ---------------------------------------- Bug #12984: `rescue *[]` should be equivalent to `rescue` as `method_call(*[])` is equivalent to `method_call` https://bugs.ruby-lang.org/issues/12984#change-81442 * Author: bughit (bug hit) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: * ruby -v: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Splatting an empty array to a construct that takes a list is supposed to be equivalent to specifying no list ```ruby def foo end foo *[] #works ``` So `rescue *[]` should be equivalent to `rescue` ```ruby begin raise 'error' #Uncaught exception rescue *[] puts 'caught' end ``` -- 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>