Bug #10436
closedruby -c and ripper inconsistency: m(&nil) {}
Description
m(&nil) {} というまちがったコードは
ruby -c でちゃんとエラーになるのに、
Ripper.sexp ではならないようです。
% cat z.rb
m(&nil) {}
% ruby -c z.rb
z.rb:1: both block arg and actual block given
% ruby -rripper -e 'p Ripper.sexp(STDIN.read)' < z.rb
[:program, [[:method_add_block, [:method_add_arg, [:fcall, [:@ident, "m", [1, 0]]], [:arg_paren, [:args_add_block, [], [:var_ref, [:@kw, "nil", [1, 3]]]]]], [:brace_block, nil, [[:void_stmt]]]]]]
% ruby -v
ruby 2.2.0dev (2014-10-27 trunk 48168) [x86_64-linux]
Files
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
This bug still occurs in the master branch. Attached is a patch that fixes the problem by overriding Ripper::SexpBuilder#on_method_add_block
. This isn't a very clean way to fix it, but I was not able to figure out a way to fix it by modifying parse.y
.
Updated by nobu (Nobuyoshi Nakada) about 5 years ago
I'm overhauling ripper to multiplex the callback values and the parser union.
https://github.com/nobu/ruby/tree/ripper.value
Updated by mame (Yusuke Endoh) over 2 years ago
- Related to Feature #18831: Block argument to `yield` added
Updated by jemmai (Jemma Issroff) about 1 year ago
This bug still exists on Ripper. Should we try revive @jeremyevans0's patch?
It is potentially worth noting that Prism creates a ParseError
: "Multiple block arguments; only one block is allowed"
Updated by yui-knk (Kaneko Yuichiro) 9 months ago
- Status changed from Open to Closed
This is solved by https://bugs.ruby-lang.org/issues/20257 (https://github.com/ruby/ruby/pull/9923).