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
4654db4f
Commit
4654db4f
authored
Apr 21, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2096 from nobu/def_in_cmdarg
Def in cmdarg
parents
5f846923
9eaddfab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
src/parse.y
src/parse.y
+7
-1
test/t/syntax.rb
test/t/syntax.rb
+7
-0
No files found.
src/parse.y
View file @
4654db4f
...
@@ -997,7 +997,7 @@ heredoc_end(parser_state *p)
...
@@ -997,7 +997,7 @@ heredoc_end(parser_state *p)
node *nd;
node *nd;
mrb_sym id;
mrb_sym id;
int num;
int num;
unsigned int
stack;
stack_type
stack;
const struct vtable *vars;
const struct vtable *vars;
}
}
...
@@ -2226,6 +2226,8 @@ primary : literal
...
@@ -2226,6 +2226,8 @@ primary : literal
{
{
p->in_def++;
p->in_def++;
$<nd>$ = local_switch(p);
$<nd>$ = local_switch(p);
$<stack>1 = p->cmdarg_stack;
p->cmdarg_stack = 0;
}
}
f_arglist
f_arglist
bodystmt
bodystmt
...
@@ -2234,12 +2236,15 @@ primary : literal
...
@@ -2234,12 +2236,15 @@ primary : literal
$$ = new_def(p, $2, $4, $5);
$$ = new_def(p, $2, $4, $5);
local_resume(p, $<nd>3);
local_resume(p, $<nd>3);
p->in_def--;
p->in_def--;
p->cmdarg_stack = $<stack>1;
}
}
| keyword_def singleton dot_or_colon {p->lstate = EXPR_FNAME;} fname
| keyword_def singleton dot_or_colon {p->lstate = EXPR_FNAME;} fname
{
{
p->in_single++;
p->in_single++;
p->lstate = EXPR_ENDFN; /* force for args */
p->lstate = EXPR_ENDFN; /* force for args */
$<nd>$ = local_switch(p);
$<nd>$ = local_switch(p);
$<stack>1 = p->cmdarg_stack;
p->cmdarg_stack = 0;
}
}
f_arglist
f_arglist
bodystmt
bodystmt
...
@@ -2248,6 +2253,7 @@ primary : literal
...
@@ -2248,6 +2253,7 @@ primary : literal
$$ = new_sdef(p, $2, $5, $7, $8);
$$ = new_sdef(p, $2, $5, $7, $8);
local_resume(p, $<nd>6);
local_resume(p, $<nd>6);
p->in_single--;
p->in_single--;
p->cmdarg_stack = $<stack>1;
}
}
| keyword_break
| keyword_break
{
{
...
...
test/t/syntax.rb
View file @
4654db4f
...
@@ -265,3 +265,10 @@ assert('parenthesed do-block in cmdarg') do
...
@@ -265,3 +265,10 @@ assert('parenthesed do-block in cmdarg') do
result
=
x
.
test
(
proc
do
:ok
;
end
)
result
=
x
.
test
(
proc
do
:ok
;
end
)
assert_equal
:ok
,
result
assert_equal
:ok
,
result
end
end
assert
(
'method definition in cmdarg'
)
do
if
false
bar
def
foo
;
self
.
each
do
end
end
end
true
end
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