parse.y: false usage of local variable

* parse.y (parser_yylex): fix false usage of local variable, it cannot
  appear in fname state [ruby-core:49659] [Bug #7408]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-11-30 06:24:40 +00:00
parent 6969043477
commit 8e2839ba2f
3 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Fri Nov 30 15:24:37 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parser_yylex): fix false usage of local variable, it cannot
appear in fname state [ruby-core:49659] [Bug #7408]
Fri Nov 30 15:20:12 2012 Eric Hodel <drbrain@segment7.net>
* lib/rubygems/package.rb: Load YAML for building gems.

View File

@ -8019,7 +8019,7 @@ parser_yylex(struct parser_params *parser)
ID ident = TOK_INTERN(!ENC_SINGLE(mb));
set_yylval_name(ident);
if (!IS_lex_state_for(last_state, EXPR_DOT) &&
if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
is_local_id(ident) && lvar_defined(ident)) {
lex_state = EXPR_END;
}

View File

@ -533,6 +533,8 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(["-we", "def foo\n"" 1.times do |a| end\n""end"], "", [], [])
feature6693 = '[ruby-core:46160]'
assert_in_out_err(["-we", "def foo\n _a=1\nend"], "", [], [], feature6693)
bug7408 = '[ruby-core:49659]'
assert_in_out_err(["-we", "def foo\n a=1\n :a\nend"], "", [], ["-e:2: warning: assigned but unused variable - a"], bug7408)
end
def test_shadowing_variable