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
Inconsistent operators precedence #9169
Comments
upvote for this one. even if using parenthesis allows to force order, this is pretty annoying |
The precedence isn't inconsistent, they're equal: We can mark this for 0.8 since it'll break configurations. :( |
Hi @mitchellh, I had the behaviour with Example : in I think inconsistent is used here to mark what is usually expected from mathematic operator precedence. |
The expectation is fair and is why this issue is still open, but the fact is that this will still be a hugely backwards incompatible change and will likely break existing configs so we need to be careful about introducing it only in a major release, which we'll plan. |
I totally get that and understand not introducing breaking changes 🙇 Maybe add a hint in the docs as @bpineau stated ? |
Add a note about operator precedence. #9169
Thanks @rottenbytes for the docs hint. I'm going to close this for now since its an HIL bug that we have over there. We'll address this perhaps in 0.9. It is easy enough to do but I want to give people some warning/time before the switch. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Hi,
Terraform Version
Terraform v0.7.4
Terraform Configuration Files
Debug Output
rendered =
var1 = 0
var2 = 2
Expected Behavior
If "%" has precedence over "+", var1 should output "2"
If "+" has precedence over "%", var2 should output "0"
Actual Behavior
In the "1 + 3 % 2" case, the addition takes precedence (outputs 0).
In the "3 % 2 + 1" case, the modulo takes precedence (outputs 2)
Same thing with a simple division ("${2 + 2 / 2}" => 2 , "${2 / 2 + 2}" => 3).
As if the values were computed left to right, without precedence considerations ?
If that so, maybe should this be stated in the interpolation doc's "Math" section (since it could be counter-intuitive) ?
Steps to Reproduce
terraform apply
The text was updated successfully, but these errors were encountered: