From d6a98ac22b0a571ec2f1fd9e7841815f000384f0 Mon Sep 17 00:00:00 2001 From: savage-tm <79486015+savage-tm@users.noreply.github.com> Date: Wed, 9 Mar 2022 17:10:06 +1300 Subject: [PATCH] Document logical operators not short-circuiting Including a note about logical operators not short-circuiting will make the documentation clearer and more useful. https://github.com/hashicorp/terraform/issues/24128 includes examples of people being caught out by this lack of clarity. --- website/docs/language/expressions/operators.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/language/expressions/operators.mdx b/website/docs/language/expressions/operators.mdx index be284e96c..cb177e8cf 100644 --- a/website/docs/language/expressions/operators.mdx +++ b/website/docs/language/expressions/operators.mdx @@ -103,3 +103,5 @@ The logical operators all expect bool values and produce bool values as results. Terraform does not have an operator for the "exclusive OR" operation. If you know that both operators are boolean values then exclusive OR is equivalent to the `!=` ("not equal") operator. + +The logical operators in Terraform do not short-circuit, meaning `var.foo || var.foo.bar` will produce an error message if `var.foo` is `null` because both `var.foo` and `var.foo.bar` are evaluated.