Actions
Feature #7730
closedTop level variables aren't checked for assigned but unused behavior
Description
In the following code, variable a in the method gets a warning, but variable b in top level code doesn't get any warning
def warning_method
a = 2
end
b = 2
warning_method
$ ruby -w no_toplevel_warnings.rb
no_toplevel_warnings.rb:2: warning: assigned but unused variable - a
It is possible to detect that b is unused if the script is required from another script.
I'd like Ruby to be able to detect that b is an assigned but unused variable.
Files
Updated by nobu (Nobuyoshi Nakada) almost 12 years ago
- File 0001-parse.y-warn-assigned-but-unused-in-toplevel.patch 0001-parse.y-warn-assigned-but-unused-in-toplevel.patch added
Agree except for -e option.
Updated by ko1 (Koichi Sasada) almost 12 years ago
- Category set to core
- Assignee set to nobu (Nobuyoshi Nakada)
- Target version set to 2.6
Nobu, do you need matz's approval?
Updated by nobu (Nobuyoshi Nakada) almost 12 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r38982.
Andrew, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
parse.y: warn assigned but unused in toplevel
- parse.y (local_push_gen): warn assigned but unused variables also in
toplevel, except for -e option. [Feature #7730] [ruby-core:51580]
Actions
Like0
Like0Like0Like0