Project

General

Profile

Actions

Defect #15667

closed

Fix shadowing variable in ApplicationHelper#textilizable

Added by Ilya S almost 11 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

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


Files

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

Updated by Toshi MARUYAMA almost 11 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.

Actions #2

Updated by Ilya S almost 11 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.

Actions #3

Updated by Go MAEDA almost 2 years ago

  • Subject changed from Fix shadowing variable to Fix shadowing variable in ApplicationHelper#textilizable
  • Category changed from Text formatting to Code cleanup/refactoring
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version set to 5.1.0
  • Resolution set to Fixed

Committed the fix. Thank you.

Actions

Also available in: Atom PDF