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
7f630d41
Commit
7f630d41
authored
Dec 23, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2684 from kou/fix-splat-and-multiple-assignments
Fix splat and multiple assignments
parents
e6184388
5ec676aa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
src/codegen.c
src/codegen.c
+4
-1
test/t/syntax.rb
test/t/syntax.rb
+32
-0
No files found.
src/codegen.c
View file @
7f630d41
...
@@ -1001,7 +1001,9 @@ gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val)
...
@@ -1001,7 +1001,9 @@ gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val)
}
}
if
(
val
)
{
if
(
val
)
{
genop
(
s
,
MKOP_AB
(
OP_MOVE
,
cursp
(),
rhs
));
genop
(
s
,
MKOP_AB
(
OP_MOVE
,
cursp
(),
rhs
));
push
();
}
else
{
pop
();
}
}
genop
(
s
,
MKOP_ABC
(
OP_APOST
,
cursp
(),
n
,
post
));
genop
(
s
,
MKOP_ABC
(
OP_APOST
,
cursp
(),
n
,
post
));
n
=
1
;
n
=
1
;
...
@@ -1016,6 +1018,7 @@ gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val)
...
@@ -1016,6 +1018,7 @@ gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val)
n
++
;
n
++
;
}
}
}
}
push
();
}
}
}
}
...
...
test/t/syntax.rb
View file @
7f630d41
...
@@ -181,6 +181,38 @@ assert('Splat and multiple assignment') do
...
@@ -181,6 +181,38 @@ assert('Splat and multiple assignment') do
assert_equal
[
1
,
nil
,
2
],
[
a
,
b
,
c
]
assert_equal
[
1
,
nil
,
2
],
[
a
,
b
,
c
]
end
end
assert
(
'Splat and multiple assignment from variable'
)
do
a
=
[
1
,
2
,
3
]
b
,
*
c
=
a
assert_equal
1
,
b
assert_equal
[
2
,
3
],
c
end
assert
(
'Splat and multiple assignment from variables'
)
do
a
=
[
1
,
2
,
3
]
b
=
[
4
,
5
,
6
,
7
]
c
,
d
,
*
e
,
f
,
g
=
*
a
,
*
b
assert_equal
1
,
c
assert_equal
2
,
d
assert_equal
[
3
,
4
,
5
],
e
assert_equal
6
,
f
assert_equal
7
,
g
end
assert
(
'Splat and multiple assignment in for'
)
do
a
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
]
for
b
,
c
,
*
d
,
e
,
f
in
[
a
]
do
end
assert_equal
1
,
b
assert_equal
2
,
c
assert_equal
[
3
,
4
,
5
],
d
assert_equal
6
,
e
assert_equal
7
,
f
end
assert
(
'Return values of case statements'
)
do
assert
(
'Return values of case statements'
)
do
a
=
[]
<<
case
1
a
=
[]
<<
case
1
when
3
then
2
when
3
then
2
...
...
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