Issue #11103 has been reported by Sigurd Berg Svela.

----------------------------------------
Bug #11103: Reassignment in if block that is not ran, causes variable to become nil
https://bugs.ruby-lang.org/issues/11103

* Author: Sigurd Berg Svela
* Status: Open
* Priority: High
* Assignee: 
* ruby -v: ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
I came across a situation where, when reassigning a variable, inside an if statement that is evaluated to false, causes the variable to become nil.
I have included the code to reproduce the problem as a file.

Changing the line
<pre>variable = [variable]</pre>
to
<pre>@variable = [@variable]</pre>
seems to work as a temporary workaround, but this still seems to me as a pretty weird bug.

---Files--------------------------------
ruby-bug.rb (649 Bytes)


-- 
https://bugs.ruby-lang.org/