Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
6e86e290
Unverified
Commit
6e86e290
authored
4 years ago
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rightward-assign by ASSOC.
[ruby-bugs:15921]
parent
b2398879
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
+22
-1
test/t/syntax.rb
test/t/syntax.rb
+9
-0
No files found.
mrbgems/mruby-compiler/core/parse.y
View file @
6e86e290
...
...
@@ -1416,7 +1416,7 @@ heredoc_end(parser_state *p)
%type <nd> singleton string string_fragment string_rep string_interp xstring regexp
%type <nd> literal numeric cpath symbol
%type <nd> top_compstmt top_stmts top_stmt
%type <nd> top_compstmt top_stmts top_stmt
rassign
%type <nd> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
%type <nd> expr_value arg_rhs primary_value
%type <nd> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
...
...
@@ -1658,9 +1658,30 @@ stmt : keyword_alias fsym {p->lstate = EXPR_FNAME;} fsym
{
$$ = new_masgn(p, $1, new_array(p, $3));
}
| rassign
| expr
;
rassign : arg tASSOC lhs
{
void_expr_error(p, $1);
$$ = new_asgn(p, $3, $1);
}
| arg tASSOC mlhs
{
void_expr_error(p, $1);
$$ = new_masgn(p, $3, $1);
}
| rassign tASSOC lhs
{
$$ = new_asgn(p, $3, $1);
}
| rassign tASSOC mlhs
{
$$ = new_masgn(p, $3, $1);
}
;
command_asgn : lhs '=' command_rhs
{
$$ = new_asgn(p, $1, $3);
...
...
This diff is collapsed.
Click to expand it.
test/t/syntax.rb
View file @
6e86e290
...
...
@@ -345,6 +345,15 @@ assert('splat object in assignment') do
assert_equal
[
2
],
(
a
=
*
o
)
end
assert
(
'right-ward assignment'
)
do
1
=>
a
assert_equal
(
1
,
a
)
13
.
divmod
(
5
)
=>
a
,
b
assert_equal
([
2
,
3
],
[
a
,
b
])
13
.
divmod
(
5
)
=>
a
,
b
=>
c
,
d
assert_equal
([
2
,
3
,
2
,
3
],
[
a
,
b
,
c
,
d
])
end
assert
(
'splat object in case statement'
)
do
o
=
Object
.
new
def
o
.
to_a
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment