From 022c7bbea98ef41556941a21ef6f0656bb49c75f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 12 Apr 2020 00:07:57 +0900 Subject: [PATCH] Relaxed of R-assign value to arg --- parse.y | 8 ++------ test/ruby/test_syntax.rb | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/parse.y b/parse.y index 794e676cfd..2c5eaf1b8f 100644 --- a/parse.y +++ b/parse.y @@ -1506,18 +1506,16 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem | expr ; -rassign : primary tASSOC lhs +rassign : arg_value tASSOC lhs { /*%%%*/ - value_expr($1); $$ = node_assign(p, $3, $1, &@$); /*% %*/ /*% ripper: assign!($3, $1) %*/ } - | primary tASSOC mlhs + | arg_value tASSOC mlhs { /*%%%*/ - value_expr($1); $$ = node_assign(p, $3, $1, &@$); /*% %*/ /*% ripper: massign!($3, $1) %*/ @@ -1525,7 +1523,6 @@ rassign : primary tASSOC lhs | rassign tASSOC lhs { /*%%%*/ - value_expr($1); $$ = node_assign(p, $3, $1, &@$); /*% %*/ /*% ripper: assign!($3, $1) %*/ @@ -1533,7 +1530,6 @@ rassign : primary tASSOC lhs | rassign tASSOC mlhs { /*%%%*/ - value_expr($1); $$ = node_assign(p, $3, $1, &@$); /*% %*/ /*% ripper: massign!($3, $1) %*/ diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 825d5e1fc0..29813cebd5 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1571,6 +1571,7 @@ eom assert_equal([2,3], eval("13.divmod(5) => a,b; [a, b]")) assert_equal([2,3,2,3], eval("13.divmod(5) => a,b => c, d; [a, b, c, d]")) assert_equal([2,3], eval("13.divmod(5)\n => a,b; [a, b]")) + assert_equal(3, eval("1+2 => a")) end private