From 0ab33ca3c74b479920b1b924ca5bb42d6d42f530 Mon Sep 17 00:00:00 2001 From: Simon Peeters Date: Mon, 7 Jun 2021 13:27:59 +0200 Subject: [PATCH] Make merge parameter data types actually backwards compatible `Hash` defaults to `Hash[Scalar,Data]` however, class/type references are valid hash values but are not covered by the `Data` type. see also https://github.com/voxpupuli/puppet-jenkins/pull/909 --- lib/puppet/functions/merge.rb | 4 ++-- spec/functions/merge_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/functions/merge.rb b/lib/puppet/functions/merge.rb index d94a7936d..b72574e60 100644 --- a/lib/puppet/functions/merge.rb +++ b/lib/puppet/functions/merge.rb @@ -40,8 +40,8 @@ # @return # The merged hash dispatch :merge2hashes do - repeated_param 'Variant[Hash, Undef, String[0,0]]', :args # this strange type is backwards compatible - return_type 'Hash' + repeated_param 'Variant[Hash[Scalar,Any], Undef, String[0,0]]', :args # this strange type is backwards compatible + return_type 'Hash[Scalar,Any]' end # @param args diff --git a/spec/functions/merge_spec.rb b/spec/functions/merge_spec.rb index da3e2e7b7..2a5747fc2 100644 --- a/spec/functions/merge_spec.rb +++ b/spec/functions/merge_spec.rb @@ -9,7 +9,7 @@ .with_params({}, 'two') \ .and_raise_error( ArgumentError, \ - Regexp.new(Regexp.escape("rejected: parameter 'args' expects a value of type Undef, Hash, or String[0, 0], got String")), + Regexp.new(Regexp.escape("rejected: parameter 'args' expects a value of type Undef, Hash[Scalar, Any], or String[0, 0], got String")), ) } it {