Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hcl2/hcl2.lark
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ identifier : /[a-zA-Z_][a-zA-Z0-9_-]*/

conditional : expression "?" _NEW_LINE_OR_COMMENT* expression _NEW_LINE_OR_COMMENT* ":" _NEW_LINE_OR_COMMENT* expression _NEW_LINE_OR_COMMENT?

?operation : unary_op | binary_op
?operation : unary_op _NEW_LINE_OR_COMMENT* | binary_op
!unary_op : ("-" | "!") expr_term
binary_op : expression binary_term
!binary_operator : "==" | "!=" | "<" | ">" | "<=" | ">=" | "-" | "*" | "/" | "%" | "&&" | "||" | "+"
Expand Down
43 changes: 43 additions & 0 deletions test/helpers/terraform-config-json/unary_operator_newline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"variable": [
{
"names": {
"type": [
"${list(string)}"
],
"default": [
[
"a"
]
],
"validation": [
{
"condition": [
"${alltrue([for n in var.names : length(n) > 0 && !contains(['host'],n) && n != \"x\"])}"
],
"error_message": [
"bad name"
]
}
],
"__start_line__": 1,
"__end_line__": 13
}
}
],
"locals": [
{
"not_then_or": [
"${!var.a || var.b}"
],
"negative_then_plus": [
"${-var.c + 2}"
],
"not_with_comment": [
"${!var.a && var.b}"
],
"__start_line__": 15,
"__end_line__": 29
}
]
}
29 changes: 29 additions & 0 deletions test/helpers/terraform-config/unary_operator_newline.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "names" {
type = list(string)
default = ["a"]
validation {
condition = alltrue([
for n in var.names :
length(n) > 0
&& !contains(["host"], n)
&& n != "x"
])
error_message = "bad name"
}
}

locals {
not_then_or = (
!var.a
|| var.b
)
negative_then_plus = (
-var.c
+ 2
)
not_with_comment = (
!var.a
# comment
&& var.b
)
}