vendored/puppet/lib/puppet/parser/scope.rb in bolt-0.15.0 vs vendored/puppet/lib/puppet/parser/scope.rb in bolt-0.16.0
- old
+ new
@@ -376,11 +376,11 @@
# Initialize our new scope. Defaults to having no parent.
def initialize(compiler, options = EMPTY_HASH)
if compiler.is_a? Puppet::Parser::AbstractCompiler
@compiler = compiler
else
- raise Puppet::DevError, "you must pass a compiler instance to a new scope object"
+ raise Puppet::DevError, _("you must pass a compiler instance to a new scope object")
end
set_options(options)
extend_with_functions_module
@@ -636,15 +636,13 @@
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
location = if position[:lineproc]
- " at #{position[:lineproc].call}"
- elsif position[:file] && position[:line]
- " at #{position[:file]}:#{position[:line]}"
+ Puppet::Util::Errors.error_location_with_space(nil, position[:lineproc].call)
else
- ""
+ Puppet::Util::Errors.error_location_with_space(position[:file], position[:line])
end
variable_not_found("#{class_name}::#{variable_name}", "#{reason}#{location}")
return nil
end
variable_not_found("#{class_name}::#{variable_name}", reason)
@@ -763,11 +761,11 @@
def setvar(name, value, options = EMPTY_HASH)
if name =~ /^[0-9]+$/
raise Puppet::ParseError.new(_("Cannot assign to a numeric match result variable '$%{name}'") % { name: name }) # unless options[:ephemeral]
end
unless name.is_a? String
- raise Puppet::ParseError, _("Scope variable name %{value0} is a %{value1}, not a string") % { value0: name.inspect, value1: name.class }
+ raise Puppet::ParseError, _("Scope variable name %{name} is a %{class_type}, not a string") % { name: name.inspect, class_type: name.class }
end
# Check for reserved variable names
if (name == VARNAME_TRUSTED || name == VARNAME_FACTS) && !options[:privileged]
raise Puppet::ParseError, _("Attempt to assign to a reserved variable name: '%{name}'") % { name: name }
@@ -1016,21 +1014,21 @@
end
end
# @api private
def find_resource_type(type)
- raise Puppet::DevError, "Scope#find_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead"
+ raise Puppet::DevError, _("Scope#find_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead")
end
# @api private
def find_builtin_resource_type(type)
- raise Puppet::DevError, "Scope#find_builtin_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead"
+ raise Puppet::DevError, _("Scope#find_builtin_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead")
end
# @api private
def find_defined_resource_type(type)
- raise Puppet::DevError, "Scope#find_defined_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead"
+ raise Puppet::DevError, _("Scope#find_defined_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead")
end
def method_missing(method, *args, &block)
method.to_s =~ /^function_(.*)$/
@@ -1040,18 +1038,18 @@
# In odd circumstances, this might not end up defined by the previous
# method, so we might as well be certain.
if respond_to? method
send(method, *args)
else
- raise Puppet::DevError, "Function #{name} not defined despite being loaded!"
+ raise Puppet::DevError, _("Function %{name} not defined despite being loaded!") % { name: name }
end
end
# To be removed when enough time has passed after puppet 5.0.0
# @api private
def resolve_type_and_titles(type, titles)
- raise Puppet::DevError, "Scope#resolve_type_and_title() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead"
+ raise Puppet::DevError, _("Scope#resolve_type_and_title() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead")
end
# Transforms references to classes to the form suitable for
# lookup in the compiler.
#
@@ -1066,10 +1064,13 @@
# @return [Array<String>] names after transformation
#
def transform_and_assert_classnames(names)
names.map do |name|
case name
+ when NilClass
+ raise ArgumentError, _("Cannot use undef as a class name")
when String
+ raise ArgumentError, _("Cannot use empty string as a class name") if name.empty?
name.sub(/^([^:]{1,2})/, '::\1')
when Puppet::Resource
assert_class_and_title(name.type, name.title)
name.title.sub(/^([^:]{1,2})/, '::\1')