diff options
| author | U.Nakamura <usa@ruby-lang.org> | 2023-09-05 20:18:23 +0900 |
|---|---|---|
| committer | U.Nakamura <usa@ruby-lang.org> | 2023-09-05 20:48:57 +0900 |
| commit | e88ffb885af222332826d46565ca405f4523ed8f (patch) | |
| tree | 6c749a8d2829608a483a73aba781a6b64f0cd779 | |
| parent | 5a7b37a6f0371ae0e74d78d368fc4583d2593c16 (diff) | |
merge revision(s) 382678d4112f4afc6272244c22924d2b004274b1: [Backport #19788]
[Bug #19788] Use the result of `tCOLON2` event
---
parse.y | 16 ++++++++--------
test/ripper/test_parser_events.rb | 17 +++++++++++++++++
test/ripper/test_scanner_events.rb | 5 +++++
3 files changed, 30 insertions(+), 8 deletions(-)
| -rw-r--r-- | parse.y | 14 | ||||
| -rw-r--r-- | test/ripper/test_parser_events.rb | 17 | ||||
| -rw-r--r-- | test/ripper/test_scanner_events.rb | 5 | ||||
| -rw-r--r-- | version.h | 2 |
4 files changed, 30 insertions, 8 deletions
@@ -1657,7 +1657,7 @@ command_asgn : lhs '=' lex_ctxt command_rhs /*%%%*/ $$ = new_attr_op_assign(p, $1, ID2VAL(idCOLON2), $3, $4, $6, &@$); /*% %*/ - /*% ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $6) %*/ + /*% ripper: opassign!(field!($1, $2, $3), $4, $6) %*/ } | defn_head f_opt_paren_args '=' command { @@ -1931,14 +1931,14 @@ command : fcall command_args %prec tLOWEST /*%%%*/ $$ = new_command_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, Qnull, &@3, &@$); /*% %*/ - /*% ripper: command_call!($1, ID2VAL(idCOLON2), $3, $4) %*/ + /*% ripper: command_call!($1, $2, $3, $4) %*/ } | primary_value tCOLON2 operation2 command_args cmd_brace_block { /*%%%*/ $$ = new_command_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, $5, &@3, &@$); /*% %*/ - /*% ripper: method_add_block!(command_call!($1, ID2VAL(idCOLON2), $3, $4), $5) %*/ + /*% ripper: method_add_block!(command_call!($1, $2, $3, $4), $5) %*/ } | keyword_super command_args { @@ -2409,7 +2409,7 @@ arg : lhs '=' lex_ctxt arg_rhs /*%%%*/ $$ = new_attr_op_assign(p, $1, ID2VAL(idCOLON2), $3, $4, $6, &@$); /*% %*/ - /*% ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $6) %*/ + /*% ripper: opassign!(field!($1, $2, $3), $4, $6) %*/ } | primary_value tCOLON2 tCONSTANT tOP_ASGN lex_ctxt arg_rhs { @@ -3910,14 +3910,14 @@ method_call : fcall paren_args $$ = new_qcall(p, ID2VAL(idCOLON2), $1, $3, $4, &@3, &@$); nd_set_line($$, @3.end_pos.lineno); /*% %*/ - /*% ripper: method_add_arg!(call!($1, ID2VAL(idCOLON2), $3), $4) %*/ + /*% ripper: method_add_arg!(call!($1, $2, $3), $4) %*/ } | primary_value tCOLON2 operation3 { /*%%%*/ $$ = new_qcall(p, ID2VAL(idCOLON2), $1, $3, Qnull, &@3, &@$); /*% %*/ - /*% ripper: call!($1, ID2VAL(idCOLON2), $3) %*/ + /*% ripper: call!($1, $2, $3) %*/ } | primary_value call_op paren_args { @@ -3933,7 +3933,7 @@ method_call : fcall paren_args $$ = new_qcall(p, ID2VAL(idCOLON2), $1, ID2VAL(idCall), $3, &@2, &@$); nd_set_line($$, @2.end_pos.lineno); /*% %*/ - /*% ripper: method_add_arg!(call!($1, ID2VAL(idCOLON2), ID2VAL(idCall)), $3) %*/ + /*% ripper: method_add_arg!(call!($1, $2, ID2VAL(idCall)), $3) %*/ } | keyword_super paren_args { diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index 5bb8f120f2..9d77b954ed 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -461,6 +461,23 @@ class TestRipper::ParserEvents < Test::Unit::TestCase assert_equal "[call(ref(self),&.,foo,[])]", tree end + def test_call_colon2 + hook = Module.new do + def on_op(op) + super("(op: #{op.inspect})") + end + def on_call(recv, name, *args) + super(recv, "(method: #{name})", *args) + end + def on_ident(name) + super("(ident: #{name.inspect})") + end + end + + parser = DummyParser.new("a::b").extend(hook) + assert_equal '[call(vcall((ident: "a")),(method: (op: "::")),(ident: "b"))]', parser.parse.to_s + end + def test_excessed_comma thru_excessed_comma = false parse("proc{|x,|}", :on_excessed_comma) {thru_excessed_comma = true} diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 13bd44e83d..f75c61765c 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -179,6 +179,11 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase scan('backtick', %q[p `make all`]) end + def test_colon2_call + assert_equal ["::"], + scan('op', %q[ a::b ]) + end + def test_comma assert_equal [','] * 6, scan('comma', %q[ m(0,1,2,3,4,5,6) ]) @@ -11,7 +11,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 4 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 236 +#define RUBY_PATCHLEVEL 237 #define RUBY_RELEASE_YEAR 2023 #define RUBY_RELEASE_MONTH 9 |
