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
d47003ae
Commit
d47003ae
authored
Nov 05, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug in argument number check with kwargs; fix #4159
parent
d9e25325
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
src/vm.c
src/vm.c
+4
-7
test/t/syntax.rb
test/t/syntax.rb
+4
-0
No files found.
src/vm.c
View file @
d47003ae
...
...
@@ -1780,11 +1780,9 @@ RETRY_TRY_BLOCK:
/* strict argument check */
if
(
mrb
->
c
->
ci
->
proc
&&
MRB_PROC_STRICT_P
(
mrb
->
c
->
ci
->
proc
))
{
if
(
argc
>=
0
&&
!
(
argc
<=
1
&&
kd
))
{
if
(
argc
<
m1
+
m2
+
kd
||
(
r
==
0
&&
argc
>
len
+
kd
))
{
argnum_error
(
mrb
,
m1
+
m2
);
goto
L_RAISE
;
}
if
(
argc
<
m1
+
m2
||
(
r
==
0
&&
argc
>
len
+
kd
))
{
argnum_error
(
mrb
,
m1
+
m2
);
goto
L_RAISE
;
}
}
/* extract first argument array to arguments */
...
...
@@ -1810,8 +1808,7 @@ RETRY_TRY_BLOCK:
kargs
=
0
;
}
else
{
mrb_value
str
=
mrb_str_new_lit
(
mrb
,
"Excepcted `Hash` as last argument for keyword arguments"
);
mrb_exc_set
(
mrb
,
mrb_exc_new_str
(
mrb
,
E_ARGUMENT_ERROR
,
str
));
argnum_error
(
mrb
,
m1
+
m2
);
goto
L_RAISE
;
}
if
(
MRB_ASPEC_KEY
(
a
)
>
0
)
{
...
...
test/t/syntax.rb
View file @
d47003ae
...
...
@@ -471,6 +471,10 @@ this is a comment that has extra after =begin and =end with tabs after it
end
assert
'keyword arguments'
do
def
m
(
a
,
b
:
1
)
[
a
,
b
]
end
assert_equal
[
1
,
1
],
m
(
1
)
assert_equal
[
1
,
2
],
m
(
1
,
b:
2
)
def
m
(
a
,
b
:)
[
a
,
b
]
end
assert_equal
[
1
,
2
],
m
(
1
,
b:
2
)
assert_raise
(
ArgumentError
)
{
m
b:
1
}
...
...
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