Found an existing rejected bug about this:
_____________________________________
http://bugs.ruby-lang.org/issues/6132

Ruby parses left to right, so it see "lo" on the assignment side of the 
if. Since no local variable "lo" has been encountered yet it must be a 
method. Ruby then encounters the assignment to lo and creates the local 
variable.
_____________________________________

I can't say this makes sense to me.  Ruby otherwise is a dynamic 
language, but with respect to local vars it's suddenly static, and the 
parser wants to identify all local vars in one left to right parse pass, 
before the code is run.

so even though at runtime

(a if a = 1)

local var 'a' already exists before it's read, the parser has statically 
bound the first 'a' to a method lookup path.

So the question is, why in a dynamic language is local variable binding 
static?  Is it a perf optimization?

-- 
Posted via http://www.ruby-forum.com/.