Forum: Ruby-core [ruby-trunk - Feature #7730][Open] Top level variables aren't checked for assigned but unused behavi

01bbb59a1c3ef9960f25a97afe7e920f?d=identicon&s=25 agrimm (Andrew Grimm) (Guest)
on 2013-01-23 07:51
(Received via mailing list)
Issue #7730 has been reported by agrimm (Andrew Grimm).

----------------------------------------
Feature #7730: Top level variables aren't checked for assigned but
unused behavior
https://bugs.ruby-lang.org/issues/7730

Author: agrimm (Andrew Grimm)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


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.
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-01-23 09:35
(Received via mailing list)
Issue #7730 has been updated by nobu (Nobuyoshi Nakada).

File 0001-parse.y-warn-assigned-but-unused-in-toplevel.patch added

Agree except for -e option.
----------------------------------------
Feature #7730: Top level variables aren't checked for assigned but
unused behavior
https://bugs.ruby-lang.org/issues/7730#change-35541

Author: agrimm (Andrew Grimm)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


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.
C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 ko1 (Koichi Sasada) (Guest)
on 2013-01-25 04:07
(Received via mailing list)
Issue #7730 has been updated by ko1 (Koichi Sasada).

Category set to core
Assignee set to nobu (Nobuyoshi Nakada)
Target version set to next minor

Nobu, do you need matz's approval?

----------------------------------------
Feature #7730: Top level variables aren't checked for assigned but
unused behavior
https://bugs.ruby-lang.org/issues/7730#change-35592

Author: agrimm (Andrew Grimm)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: core
Target version: next minor


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.
This topic is locked and can not be replied to.