[Fix #3591] Handle modifier if in Variable#reference!() #7336
Assignments in modifier if/unless conditions are special. The following program
A preceding assignment to
Assignments in modifier if/unless conditions are special. The following program exits with the error "undefined local variable or method `a' for main:Object" when executed. ``` puts a if (a = @x) ``` A preceding assignment to `a` is needed to put it in scope. So there are no useless assignments in ``` a = nil puts a if (a = @x) ```
It has to be intentional. Has to be. From The Ruby Language FAQ:
Here's an even weirder example:
a = nil if false # This line is needed. puts a if (a = @x) # This is fine.
It's not about assignments being executed. It's all about being seen prior to use. And