Last active
December 30, 2015 16:09
-
-
Save jimsynz/7853213 to your computer and use it in GitHub Desktop.
Surprised that you can't just ram a `rescue` or `ensure` inside a block without an enclosing `begin`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Trying Ruby #{RUBY_DESCRIPTION}" | |
eval <<-'EOF' | |
proc do | |
puts "hello" | |
rescue Exception => e | |
puts "Exception #{e}" | |
ensure | |
puts "goodbye" | |
end | |
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rvm all do ruby source.rb | |
Trying Ruby jruby 1.7.5 (1.9.3p392) 2013-10-07 74e9291 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_13-b20 [darwin-x86_64] | |
SyntaxError: (eval):3: syntax error, unexpected kRESCUE | |
rescue Exception => e | |
^ | |
eval at org/jruby/RubyKernel.java:1121 | |
(root) at source.rb:3 | |
Trying Ruby rubinius 2.0.0 (2.1.0 2013-10-04 JI) [x86_64-darwin12.5.0] | |
A syntax error has occurred: | |
expecting keyword_end: (eval):3:8 | |
Code: | |
rescue Exception => e | |
^ | |
Backtrace: | |
Rubinius::ToolSet::Runtime::Melbourne#syntax_error at .rvm/rubies/rbx-2.0.0/runtime/gems/rubinius-melbourne-2.0.0.17/lib | |
/rubinius/melbourne.rbc:68 | |
Rubinius::ToolSet::Runtime::Melbourne#parse_string at .rvm/rubies/rbx-2.0.0/runtime/gems/rubinius-melbourne-2.0.0.17/lib | |
/rubinius/melbourne.rbc:72 | |
Rubinius::ToolSet::Runtime::Compiler::StringParser(Rubinius::ToolSet::Runtime::Compiler::EvalParser)#parse at .rvm/rubies/rbx-2.0.0/runtime | |
/gems/rubinius-compiler-2.0.4 | |
/lib/rubinius/compiler | |
/stages.rbc:241 | |
Rubinius::ToolSet::Runtime::Compiler::Parser(Rubinius::ToolSet::Runtime::Compiler::EvalParser)#run at .rvm/rubies/rbx-2.0.0/runtime/gems | |
/rubinius-compiler-2.0.4/lib/rubinius | |
/compiler/stages.rbc:207 | |
Rubinius::ToolSet::Runtime::Compiler#run at .rvm/rubies/rbx-2.0.0/runtime/gems/rubinius-compiler-2.0.4/lib/rubinius | |
/compiler/compiler.rbc:361 | |
Rubinius::ToolSet::Runtime::Compiler.compile_eval at .rvm/rubies/rbx-2.0.0/runtime/gems/rubinius-compiler-2.0.4/lib/rubinius | |
/compiler/compiler.rbc:305 | |
Rubinius::ToolSet::Runtime::Compiler.construct_block at .rvm/rubies/rbx-2.0.0/runtime/gems/rubinius-compiler-2.0.4/lib/rubinius | |
/compiler/compiler.rbc:317 | |
Kernel(Object)#eval at kernel/common/eval.rb:174 | |
Object#__script__ at source.rb:3 | |
Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66 | |
Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:182 | |
Rubinius::Loader#script at kernel/loader.rb:641 | |
Rubinius::Loader#main at kernel/loader.rb:822 | |
Trying Ruby rubinius 2.2.0 (2.1.0 f66ada69 2013-11-15 JI) [x86_64-darwin13.0.0] | |
A syntax error has occurred: | |
expecting keyword_end: (eval):3:8 | |
Code: | |
rescue Exception => e | |
^ | |
Backtrace: | |
Rubinius::ToolSet::Runtime::Melbourne#syntax_error at .rvm/rubies/rbx-2.2.0/runtime/gems/rubinius-melbourne-2.0.0.19/lib | |
/rubinius/melbourne.rbc:68 | |
Rubinius::ToolSet::Runtime::Melbourne#parse_string at .rvm/rubies/rbx-2.2.0/runtime/gems/rubinius-melbourne-2.0.0.19/lib | |
/rubinius/melbourne.rbc:72 | |
Rubinius::ToolSet::Runtime::Compiler::StringParser(Rubinius::ToolSet::Runtime::Compiler::EvalParser)#parse at .rvm/rubies/rbx-2.2.0/runtime | |
/gems/rubinius-compiler-2.0.4 | |
/lib/rubinius/compiler | |
/stages.rbc:241 | |
Rubinius::ToolSet::Runtime::Compiler::Parser(Rubinius::ToolSet::Runtime::Compiler::EvalParser)#run at .rvm/rubies/rbx-2.2.0/runtime/gems | |
/rubinius-compiler-2.0.4/lib/rubinius | |
/compiler/stages.rbc:207 | |
Rubinius::ToolSet::Runtime::Compiler#run at .rvm/rubies/rbx-2.2.0/runtime/gems/rubinius-compiler-2.0.4/lib/rubinius | |
/compiler/compiler.rbc:361 | |
Rubinius::ToolSet::Runtime::Compiler.compile_eval at .rvm/rubies/rbx-2.2.0/runtime/gems/rubinius-compiler-2.0.4/lib/rubinius | |
/compiler/compiler.rbc:305 | |
Rubinius::ToolSet::Runtime::Compiler.construct_block at .rvm/rubies/rbx-2.2.0/runtime/gems/rubinius-compiler-2.0.4/lib/rubinius | |
/compiler/compiler.rbc:317 | |
Kernel(Object)#eval at kernel/common/eval.rb:174 | |
Object#__script__ at source.rb:3 | |
Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66 | |
Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:193 | |
Rubinius::Loader#script at kernel/loader.rb:649 | |
Rubinius::Loader#main at kernel/loader.rb:831 | |
Trying Ruby ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0] | |
source.rb:3:in `eval': (eval):3: syntax error, unexpected keyword_rescue, expecting keyword_end (SyntaxError) | |
rescue Exception => e | |
^ | |
(eval):5: syntax error, unexpected keyword_ensure, expecting keyword_end | |
from source.rb:3:in `<main>' | |
Trying Ruby ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0] | |
source.rb:3:in `eval': (eval):3: syntax error, unexpected keyword_rescue, expecting keyword_end (SyntaxError) | |
rescue Exception => e | |
^ | |
(eval):5: syntax error, unexpected keyword_ensure, expecting keyword_end | |
from source.rb:3:in `<main>' | |
Trying Ruby ruby 2.1.0dev (2013-11-23 trunk 43807) [x86_64-darwin13.0] | |
source.rb:3:in `eval': (eval):3: syntax error, unexpected keyword_rescue, expecting keyword_end (SyntaxError) | |
rescue Exception => e | |
^ | |
(eval):5: syntax error, unexpected keyword_ensure, expecting keyword_end | |
from source.rb:3:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
have you found a workaround?