Skip to content

Commit b1ac4d5

Browse files
committed
(maint) Prevent multiple lookups of global scope
Before this commit, the method Closure#call_by_name would always perform two lookups of Puppet[:global_scope]. This commit ensures that only one lookup is made.
1 parent 4e7bbb0 commit b1ac4d5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/puppet/pops/evaluator/closure.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def invoke(instance, calling_scope, args, &block)
4141

4242
# Call closure with argument assignment by name
4343
def call_by_name(args_hash, enforce_parameters)
44+
closure_scope = enclosing_scope
4445
if enforce_parameters
45-
closure_scope = enclosing_scope
4646
# Push a temporary parameter scope used while resolving the parameter defaults
4747
closure_scope.with_parameter_scope(closure_name, parameter_names) do |param_scope|
4848
# Assign all non-nil values, even those that represent non-existent paramaters.
@@ -65,7 +65,7 @@ def call_by_name(args_hash, enforce_parameters)
6565
Types::TypeMismatchDescriber.validate_parameters(closure_name, params_struct, args_hash)
6666
end
6767

68-
@evaluator.evaluate_block_with_bindings(enclosing_scope, args_hash, @model.body)
68+
@evaluator.evaluate_block_with_bindings(closure_scope, args_hash, @model.body)
6969
end
7070

7171
def parameters

0 commit comments

Comments
 (0)