Skip to content

Commit

Permalink
Document logical operators not short-circuiting
Browse files Browse the repository at this point in the history
Including a note about logical operators not short-circuiting will make the documentation clearer and more useful. hashicorp#24128 includes examples of people being caught out by this lack of clarity.
  • Loading branch information
savage-tm committed Mar 9, 2022
1 parent e543dda commit d6a98ac
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions website/docs/language/expressions/operators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit d6a98ac

Please sign in to comment.