Actions
Bug #1618
closedKernel.catch without Arguments
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-06-01 trunk 23614) [i686-linux]
Backport:
Description
=begin
In 1.9 Kernel.catch can be called with neither a symbol nor object to catch, e.g.:
catch { }
In 1.8 this usage raised an ArgumentError.
The test/ruby/test_system.rb file from the Ruby repository contains:
def valid_syntax?(code, fname)
code.force_encoding("ascii-8bit")
code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) {
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
}
catch {|tag| eval(code, binding, fname, 0)}
end
With the help of #rubyspec, I've reduced this down to:
catch {|wtf| throw wtf}
This passes an instance of Object into the block.
So, assuming that this must be a feature, could the documentation be updated with an explanation, and suggestions proffered as to the purpose of this invocation?
=end
Updated by nobu (Nobuyoshi Nakada) almost 15 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23675.
=end
Actions
Like0
Like0