Defect #15667

Fix shadowing variable

Added by Ilya S almost 9 years ago. Updated almost 9 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Text formatting
Target version:-
Resolution: Affected version:2.4.1

Description

fix using two different objects with same name, may cause problems

textilizable.diff Magnifier (1.09 KB) Ilya S, 2013-12-10 11:34

History

#1 Updated by Toshi MARUYAMA almost 9 years ago

I think it does not cause problem.

def test(text)
  "test " + yield("yield " + text)
end

text = "aaaa" 
text = test(text) do |text|
  puts text
  "block " + text
end

puts text
$ ruby a.rb 
yield aaaa
test block yield aaaa

r10209 has tests.

#2 Updated by Ilya S almost 9 years ago

yes, it isn't in this case, but may cause, because you create two different objects in same scope. Do you really think that's ok? Why do you rely on assumption that this piece of code will interprete right, instead of write it right?

and one more thing: code like this really hard to read, and maintain.

Also available in: Atom PDF