mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: lex by lvar
* parse.y (parse_ident): disable tLPAREN_ARG state by local variable. [ruby-list:50578] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
698f2db224
commit
50f7d64f41
2 changed files with 12 additions and 1 deletions
2
parse.y
2
parse.y
|
@ -8468,7 +8468,7 @@ parser_yylex(struct parser_params *parser)
|
||||||
"an argument list, not a decomposed argument");
|
"an argument list, not a decomposed argument");
|
||||||
}
|
}
|
||||||
else if (lex_state == (EXPR_END|EXPR_LABEL) && space_seen) {
|
else if (lex_state == (EXPR_END|EXPR_LABEL) && space_seen) {
|
||||||
rb_warning0("don't put space before argument parentheses");
|
c = tLPAREN_ARG;
|
||||||
}
|
}
|
||||||
paren_nest++;
|
paren_nest++;
|
||||||
COND_PUSH(0);
|
COND_PUSH(0);
|
||||||
|
|
|
@ -1054,6 +1054,17 @@ x = __ENCODING__
|
||||||
assert_not_match(/unexpected tSTRING_END/, e)
|
assert_not_match(/unexpected tSTRING_END/, e)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_lparenarg
|
||||||
|
o = Struct.new(:x).new
|
||||||
|
def o.i(x)
|
||||||
|
self.x = x
|
||||||
|
end
|
||||||
|
o.instance_eval {i (-1.3).abs}
|
||||||
|
assert_equal(1.3, o.x)
|
||||||
|
o.instance_eval {i = 0; i (-1.3).abs}
|
||||||
|
assert_equal(1.3, o.x)
|
||||||
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
def test_past_scope_variable
|
def test_past_scope_variable
|
||||||
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}
|
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue