Feature #8691

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

Added by Andrew Grimm over 1 year ago. Updated over 1 year ago.

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

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 Updated by Andrew Grimm over 1 year 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 Updated by Zachary Scott over 1 year ago

  • Status changed from Open to Feedback

@andrew should we close this ticket then?

#3 Updated by Andrew Grimm over 1 year 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 Updated by Zachary Scott over 1 year ago

  • Status changed from Feedback to Closed

closing, see ruby-core:57091

Also available in: Atom PDF