Skip to content

Backport #9269 to 8.5.1 #9273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 29, 2024

Conversation

joshcooper
Copy link
Contributor

Previously, class parameters of the form `Integer[-1] $param` would fail
compilation, because the value `-1` was lexed as a UnaryMinusExpression
containing a LiteralInteger. And since the LiteralEvaluator didn't implement the
`literal_UnaryMinusExpression` method, the visitor called `literal_XXX` for each
ancestor class, until reaching `literal_Object`, which always raises.

This adds the `literal_UnaryMinusExpression` method and returns -1 times
the expression it wraps. This is similar to how the TypeParser interprets
UnaryMinusExpressions[1].

[1] https://github.com/puppetlabs/puppet/blob/8.5.0/lib/puppet/pops/types/type_parser.rb#L161
If strict is off, the issue will be ignored. If strict is warning, then a
warning will be reported, but compilation will continue:

    Warning: The parameter '$i' must be a literal type, not a Puppet::Pops::Model::AccessExpression

If strict is error, then compilation will fail.
The "undef to nil" test is special because otherwise the value nil when
interpolated in the name of the test results in empty string.
@joshcooper joshcooper requested a review from a team as a code owner February 29, 2024 18:57
@joshcooper joshcooper marked this pull request as draft February 29, 2024 19:12
@joshcooper joshcooper marked this pull request as ready for review February 29, 2024 21:56
@joshcooper joshcooper merged commit 939d5d4 into puppetlabs:8.5.1_release Feb 29, 2024
@joshcooper joshcooper deleted the backport_unary_851 branch February 29, 2024 22:05
@joshcooper joshcooper added the bug Something isn't working label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants