Project

General

Profile

Bug #10436 ยป ripper-block_dup_check-10436.patch

jeremyevans0 (Jeremy Evans), 08/21/2019 03:48 AM

View differences:

ext/ripper/lib/ripper/sexp.rb
end
class SexpBuilder < ::Ripper #:nodoc:
def error?
super || (defined?(@error) && @error)
end
private
def dedent_element(e, width)
......
val
end
def on_method_add_block(*args)
if ((args[0][0] == :command && args[0][-1][0] == :args_add_block) ||
(args[0][0] == :method_add_arg && args[0][-1][0] == :arg_paren && args[0][-1][1][0] == :args_add_block)) &&
(args[1][0] == :brace_block || args[1][0] == :do_block)
@error = true
end
args.unshift :method_add_block
args
end
events = private_instance_methods(false).grep(/\Aon_/) {$'.to_sym}
(PARSER_EVENTS - events).each do |event|
module_eval(<<-End, __FILE__, __LINE__ + 1)
test/ripper/test_sexp.rb
assert_nil Ripper.sexp("/+/")
end
def test_block_dup_check
assert_nil Ripper.sexp("m(&nil) {}")
assert_nil Ripper.sexp("m(1, &nil) {}")
assert_nil Ripper.sexp("m(&nil) do end")
assert_nil Ripper.sexp("m(1, **h, &nil) do end")
assert_nil Ripper.sexp("m &nil do end")
assert_nil Ripper.sexp("m 1, &nil do end")
assert_nil Ripper.sexp("m 1, *a, **kw, &nil do end")
end
def test_regexp_content
sexp = Ripper.sexp('//')
assert_nil search_sexp(:@tstring_content, search_sexp(:regexp_literal, sexp))
    (1-1/1)