elixir
elixir copied to clipboard
Variables defined in cond head should not leak
This is especially annoying in cases like this:
cond do
name=opt[:name] -> process_name(name)
short=opt[:short] -> process_name(name)
true -> ""
end
There is no compilation error, but name in the second call to process_name will be nil.
You probably have noticed, but the same leaking happens in if and unless clause, too.
@jw2013 if and unless should leak. They don't have "clauses".
@jw2013 They don't leak, the modify enclosing scope. See this doc
@ericmj @alco Thanks for the explanation.