-
Notifications
You must be signed in to change notification settings - Fork 451
Null as Identifier in HCL #5780
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
Conversation
d6da229
to
dafc9b8
Compare
I know we usually don't force push, I just neede to get the PR displaying right |
attribute | ||
: Identifier ASSIGN expression | ||
: (Identifier | NULL) ASSIGN expression | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat surprised not to see any corresponding change in the tree package here around:
class Attribute implements BodyContent, Expression { |
Is that just a problem with my expectations? Could you help explain why such a change wasn't needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Token NULL
here is not the OOP null
as no object. In the G4 the NULL
is a special identifier with the value "null"
and will be parsed into a Hcl.Identifier
with the name="null"
.
The NULL
-Token is only used in 2 locations to selectively allow "null"
as an identifier in these locations (as object keys and variable names). This way we still reject corrupt files at the parser level when null
is used in a different location or no identifier is provided.
You see no change in the Hcl.Tree
because none is needed to represent an Hcl.Identifier
with value "null"
. And I choose the minimal change.
We could think about mirroring this setup with a specialization of Hcl.Identifier
to explicitly model "null"
as an identifier in these cases.
I think the gain would be very low, as null is simply valid in these cases, and the risk of introducing new LST elements is higher.
For example:
terraform {
required_providers {
null = {
source = "hashicorp/null"
version = "=3.2.3"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While writing these lines, I realize that NULL
is probably not a great name for the Token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The g4 change and related changes look fine to me.
I am only slightly concerned with the changes to the JsonPath* classes. It's hard to tell for sure, but I hope they are only whitespace change as there's no reason for these to be altered. Github's "Hide Whitespace" option in the review interface hides only some of them, but they all look trivial.
agree they look strange let me reset to main |
@greg-at-moderne the answer is, I executd the |
What's changed?
null
is a valid key for objects and variables in HCL. We blocked it as syntactically error.What's your motivation?
allow basic setups as
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
null
seems to be common in TFAny additional context
Checklist