This is a known quirk of parsing; variables are considered "declared"
only after the first assigment to them is found by the parser. Here,
the assigment is "lexically" after the access operation.

This could be considered a bug, I think it might even be already filed
at http://bugs.ruby-lang.org/. But it certainly is a code smell 
first, it's bad to assign to variables in an if condition (MRI even
warns you about it), second, it's bad to include any even slightly
non-trivial expression in the short if form.


You can also verify that it parses differently: install the
ruby_parser gem and use "ruby_parse" command to parse the following
code:

local1 if local1 = "created"

if local1 = "created"
	local1
end

You get this:

s(:block,
 s(:if, s(:lasgn, :local1, s(:str, "created")), s(:call, nil, :local1), nil),
 s(:if, s(:lasgn, :local1, s(:str, "created")), s(:lvar, :local1), nil))

In the first case, the "local1" is interpreted as a function call; in
the second, as a local variable reference.

-- Matma Rex