summaryrefslogtreecommitdiff
path: root/ops_test.go
AgeCommit message (Collapse)Author
2024-09-24Preserve marks when traversing unknown valuesJames Bardin
When traversing an unknown value or a DynamicVal, the marks from that initial value must be preserved for HCL Index and GetAttr operations. This mirrors the behavior of GetAttr and Index when used directly the underlying cty values.
2023-02-28[COMPLIANCE] Add Copyright and License Headers (#586)hashicorp-copywrite[bot]
* [COMPLIANCE] Add Copyright and License Headers * add copywrite file and revert headers in testdata --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Liam Cervante <liam.cervante@hashicorp.com>
2021-06-25hcl: More helpful error messages in Index and GetAttrMartin Atkins
When we first implemented these helpers we tried to anticipate a few situations that seemed likely to come up and implement specialized error messages for them, but in the intervening years we've seen a number of other situations crop up with some regularity. Given that, I've added a few more specialized error message cases to both of these functions, so we'll return the most generic error messages in fewer situations. Because hcl.Index and hcl.GetAttr are quite general functions used for lots of different application-specific purposes alongside their part in the implementation of the index and attribute access operators, I've intentionally kept these messages quite vague in the suggestions they make, which does mean that unfortunately users will probably need to do some further research to find a suitable resolution to these messages. Hopefully the extra context at least gives the user a better hook for that further research. Later we could consider putting some pre-checks in the actual operator implementations that would catch some of these prior to calling the generic functions and return a more directly-prescriptive error message which assumes we're in an expression evaluation context, but I'd like to see how these new messages are received in practice first, to see if that additional complexity would be warranted.
2021-02-26avoid panics with marked index valuesJames Bardin
2020-11-26Fix panic traversing marked listAlisdair McDiarmid
We need to unmark the result of HasIndex in order to compare it with true or false without a panic.
2020-09-24Fix panic when traversing marked map valueAlisdair McDiarmid
2019-09-09Unfold the "hcl" directory up into the rootMartin Atkins
The main HCL package is more visible this way, and so it's easier than having to pick it out from dozens of other package directories.