Project

General

Profile

Feature #8691

Add warning for variable that is re-assigned but not re-used

Added by Andrew Grimm over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
[ruby-core:56184]

Description

The following code

def reassigned_unused
a = 42
b = a.to_s
a = 56
b
end

Does not currently generate an "assigned but unused variable" warning about the second assignment to "a".

Is it feasible to create a warning for such a scenario?

History

#1 [ruby-core:57091] Updated by Andrew Grimm over 2 years ago

A third party tool that I use, called Rubocop, has implemented such functionality. https://github.com/bbatsov/rubocop/issues/458

So I don't really require this functionality in MRI any more.

#2 [ruby-core:57238] Updated by Zachary Scott over 2 years ago

  • Status changed from Open to Feedback

@andrew should we close this ticket then?

#3 [ruby-core:57250] Updated by Andrew Grimm over 2 years ago

Yes, close the ticket. If someone else wants the functionality, or has implemented the functionality and wants to submit a patch, they can open another ticket.

#4 [ruby-core:57337] Updated by Zachary Scott over 2 years ago

  • Status changed from Feedback to Closed

closing, see ruby-core:57091

Also available in: Atom PDF