Commit Graph

17 Commits

Author SHA1 Message Date
Pam Selle e0dbad0dba
Merge pull request #440 from hashicorp/pselle/mark-objs
Mark objects with keys that are sensitive
2021-01-05 16:11:54 -05:00
Alisdair McDiarmid 4ace3e69bf
Merge pull request #438 from hashicorp/alisdair/marked-for-expression-conditional
hclsyntax: Fix for expression marked conditional
2021-01-05 08:55:23 -05:00
Pam Selle b6fc34e719 Mark objects with keys that are sensitive
This adjusts prior behavior that would error to now allow keys that
are marked; those marks are removed in evaluation in order to give
a valid string for the map key, but the resulting object or tuple
is marked as a whole with whatever mark the key contained, ensuring
marks are maintained.
2021-01-04 15:54:08 -05:00
Alisdair McDiarmid fe026c3c98 hclsyntax: Fix for expression marked conditional
Using marked values in a for expression conditional expression would
previously panic due to calling `.False()` on the result of the
expression.

This commit makes two changes:

- Unmark the conditional expression value before testing if it is false;
- Merge any marks from the conditional into the resulting marks for the
  for expression.
2021-01-04 11:30:24 -05:00
Alisdair McDiarmid 9e21ad5861 Test splat of collection including marked elements 2020-12-18 14:30:01 -05:00
Alisdair McDiarmid 7f17fe4202 hclsyntax: Fix panic for marked collection splat 2020-12-18 13:27:49 -05:00
Pam Selle d0b4a6862d
Merge pull request #433 from hashicorp/pselle/marked-for
Return an error for invalid for expressions with marks
2020-12-17 10:34:09 -05:00
Pam Selle c227eb4f81 Error if attempting to use marked value as key
When evaluating an HCL expression attempting
to use a marked value as an object key,
return an error rather than falling through
to the cty panic. The error style mimics similar
errors in the area.
2020-12-16 12:01:39 -05:00
Pam Selle dfa6aff940 Return an error if a for expression attempts to use a marked value as a key 2020-12-15 14:38:30 -05:00
Alisdair McDiarmid b857e806ff hclsyntax: Fix panic when expanding marked funargs
Functions which accept multiple parameters can be called with the
expansion operator, `...`. When doing so, we must unmark the expanded
argument value before transforming it into a collection of function
arguments. To ensure that any marks applied to the collection are
preserved, we transfer the collection marks to the individual elements
as we build the argument list.
2020-12-09 15:00:19 -05:00
Pam Selle 3b45fd43af Unmark values before testing for truth in conditionals
In conditional expressions that involve a marked value,
Unmark the value before inspecting its truthiness,
to avoid a mark panic in cty
2020-12-03 10:51:18 -05:00
Rémi Lapeyre 128a2f1879
hclsyntax: null[*] to return an empty tuple
The rules for the splat operator call for it to return an empty tuple
when its operand is null, but this rule was previously being
overridden by another rule that a value whose type is unknown
causes the operator to return an unknown value of unknown
type.

This was initially reported and discussed in Terraform, under
hashicorp/terraform#26746.
2020-11-18 14:26:15 -08:00
Alisdair McDiarmid 39015a09a3 hclsyntax: Fix for expressions over marked values
A for expression over a marked collection should result in a new
collection with the same marks. Previously this would fail with a type
error.
2020-10-08 16:07:45 -04:00
Kristin Laemmert 1f97062183 hclsyntax: return cty.DynamicVal when encountering (...) and unknown
vals
2020-06-03 09:33:38 -04:00
Kristin Laemmert d9969e8731 hclsyntax: do not panic when encountering a null + sequence (...)
Previously functions such as concat() would result in a panic if there
was a null element and a sequence, as in the included test. This PR adds
a check if the error index is outside of the range of arguments and
crafts an error that references the entire function instead of the null
argument.
2020-06-03 09:13:36 -04:00
Martin Atkins 22ba006718 hclsyntax: Allow parens to force mapping key to be expression
Our error message for the ambiguous situation recommends doing this, but
the parser didn't actually previously allow it. Now we'll accept the form
that the error message recommends.

As before, we also accept a template with an interpolation sequence as
a disambiguation, but the error message doesn't mention that because it's
no longer idiomatic to use an inline string template containing just a
single interpolation sequence.
2019-10-01 15:59:10 -07:00
Martin Atkins 6c4344623b Unfold the "hcl" directory up into the root
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.
2019-09-09 16:08:19 -07:00