vendored/puppet/lib/puppet/parser/scope.rb in bolt-0.10.0 vs vendored/puppet/lib/puppet/parser/scope.rb in bolt-0.11.0

- old
+ new

@@ -609,19 +609,30 @@ leaf_name = fqn[ (leaf_index+2)..-1 ] class_name = fqn[ 0, leaf_index ] begin qs = qualified_scope(class_name) unless qs.nil? + return qs.get_local_variable(leaf_name) if qs.has_local_variable?(leaf_name) iscope = qs.inherited_scope return lookup_qualified_variable("#{iscope.source.name}::#{leaf_name}", options) unless iscope.nil? end rescue RuntimeError => e # because a failure to find the class, or inherited should be reported against given name return handle_not_found(class_name, leaf_name, options, e.message) end end # report with leading '::' by using empty class_name return handle_not_found('', fqn, options) + end + + # @api private + def has_local_variable?(name) + @ephemeral.last.include?(name) + end + + # @api private + def get_local_variable(name) + @ephemeral.last[name] end def handle_not_found(class_name, variable_name, position, reason = nil) unless Puppet[:strict_variables] # Do not issue warning if strict variables are on, as an error will be raised by variable_not_found