Project

General

Profile

Bug #13809

Unused variable warning does not occur when a method with the same name was called

Added by pocke (Masataka Kuwabara) about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
[ruby-core:82368]

Description

problem

a = 1
a()

a is unused, but ruby -cw does not add warning for this code.

$ ruby -cw test.rb
Syntax OK

Cause

The parser changes mode by lvar definition. At that time, parser checks whether lvar is defined that is with same name.
https://github.com/ruby/ruby/blob/6ee82564fac2745e45154938b5b75d9f5ab70b58/parse.y#L7886
Then, if lvar with same name is defined, the lvar is marked as used.
https://github.com/ruby/ruby/blob/6ee82564fac2745e45154938b5b75d9f5ab70b58/parse.y#L10494

Associated revisions

Revision 29b114a1
Added by nobu (Nobuyoshi Nakada) about 2 years ago

parse.y: set used flag in gettable

  • parse.y (dvar_defined_ref, dvar_defined): rename macros. only
    gettable uses the former. assignable should not set LVAR_USED
    flag.

  • parse.y (gettable_gen): set used flag on local/dynamic variables
    instead of setting in lexer. [ruby-core:82368] [Bug #13809]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59585
Added by nobu (Nobuyoshi Nakada) about 2 years ago

parse.y: set used flag in gettable

  • parse.y (dvar_defined_ref, dvar_defined): rename macros. only
    gettable uses the former. assignable should not set LVAR_USED
    flag.

  • parse.y (gettable_gen): set used flag on local/dynamic variables
    instead of setting in lexer. [ruby-core:82368] [Bug #13809]

Revision 59585
Added by nobu (Nobuyoshi Nakada) about 2 years ago

parse.y: set used flag in gettable

  • parse.y (dvar_defined_ref, dvar_defined): rename macros. only
    gettable uses the former. assignable should not set LVAR_USED
    flag.

  • parse.y (gettable_gen): set used flag on local/dynamic variables
    instead of setting in lexer. [ruby-core:82368] [Bug #13809]

Revision 59585
Added by nobu (Nobuyoshi Nakada) about 2 years ago

parse.y: set used flag in gettable

  • parse.y (dvar_defined_ref, dvar_defined): rename macros. only
    gettable uses the former. assignable should not set LVAR_USED
    flag.

  • parse.y (gettable_gen): set used flag on local/dynamic variables
    instead of setting in lexer. [ruby-core:82368] [Bug #13809]

History

#1

Updated by nobu (Nobuyoshi Nakada) about 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r59585.


parse.y: set used flag in gettable

  • parse.y (dvar_defined_ref, dvar_defined): rename macros. only
    gettable uses the former. assignable should not set LVAR_USED
    flag.

  • parse.y (gettable_gen): set used flag on local/dynamic variables
    instead of setting in lexer. [ruby-core:82368] [Bug #13809]

Also available in: Atom PDF