bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

Cannot parse boolean condition on type #255

Closed PierreR closed 5 years ago

PierreR commented 6 years ago

Something that probably should be supported ?


  if (Integer($::operatingsystemmajrelease) < 7){
    ...
  }
x swarm.worker.testing: cannot parse ./modules/docker/manifests/init.pp:492:51:
    |
492 |   if ($::operatingsystem == 'CentOS') and (Integer($::operatingsystemmajrelease) < 7){
    |                                                   ^
unexpected '('
expecting "!=", "!~", "<<", "<=", "==", "=~", ">=", ">>", "and", "in", "or", ')', '*', '+', '-', '.', '/', '<', '>', or '['
bartavelle commented 6 years ago

Amusing :(

bartavelle commented 6 years ago

I tried switching the parsing order between functions and datatypes, does that help?

PierreR commented 6 years ago

I initially thought this was a mere check but it is actually a cast ... So it seems from the tests of this PR. This language is so ... surprising.

bartavelle commented 6 years ago

What does that mean in the first place? Datatypes can be called like functions and this results in a cast sometimes? Or is that just Integer?

PierreR commented 5 years ago

I have found this info in the spec: https://github.com/puppetlabs/puppet-specifications/blob/3c0f46adf68000c08dcb04fa4a61e73560a6787b/language/types_values_variables.md#integernew

bartavelle commented 5 years ago

beuh :(

bartavelle commented 5 years ago

Do you mind checking if my last commit breaks stuff?

PierreR commented 5 years ago

Tested against a couple of nodes and it works without issues.

Thanks.