Bug #7734

Post IF - undefined local variable

Added by Сергей Е about 1 year ago. Updated about 1 year ago.

[ruby-core:51593]
Status:Rejected
Priority:Normal
Assignee:-
Category:core
Target version:1.9.3
ruby -v:1.9.3p374 Backport:

Description

hash[:tree] = tree if (tree = getpathtreearray(params, path, deep + 1)) && ! tree.empty?

=> undefined local variable or method `tree' for #Content:0x92d96b0

but

if (tree = getpathtreearray(params, path, deep + 1)) && ! tree.empty?
hash[:tree] = tree
end

=> WORK FINE!

Content - is a: class Content < ActiveRecord::Base in Ruby on Rails 3.2.11

History

#1 Updated by Yukihiro Matsumoto about 1 year ago

  • Status changed from Open to Rejected

The local variables are considered defined after the assignments, so that in above case, tree appears before the assignment is intentionally left undefined.

Matz.

Also available in: Atom PDF