Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PUP-11981) Syntactically incorrect types cause nil
This commit adds logic to validate class parameters are literal and provides a descriptive warning if parameter(s) are not literal, adds QualifiedReference and AccessExpression as a valid literal values & updates spec tests to check for more cases of invalid class parameters and any that broke as a result of the changes. The logic to validate class parameters is done in internal_check_parameter_type_literal method where the appropriate literal method is called on each parameter. There are different literal methods for each literal object/type [1]. For example if the parameter is String type, then literal_LiteralString is called. If a parameter is found to be not literal, then a :not_literal will be thrown & warning message with the invalid class parameter and its type will be printed. QualifiedReference is considered literal since it is a literal reference, however, there is a possibility it could be a faulty dangling reference that doesn't reference anything. AccessExpresions are anything with the Access Operator ([ ]) such as Optional[String] or Variant[Boolean, Float] [2]. Since these are valid class parameters, AccessExpressions are also considered literal. The logic to add QualifiedReference & AccessExpression as valid literal values is done in the literal_QualifiedReference & literal_AccessExpression methods. The literal_AccessExpression works by validating each key in the expression is literal. The literal_QualifiedReference method looks at o.value, similar to other existing literal methods like literal_LiteralString. [1] http://puppet-on-the-edge.blogspot.com/2014/02/puppet-internals-polymorphic-dispatch.html [2] https://github.com/puppetlabs/puppet-specifications/blob/master/language/expressions.md#assignment-operator For more information on this issue, see puppetlabs#9140 (cherry picked from commit adbb02c)
- Loading branch information