Commit Graph

1227 Commits

Author SHA1 Message Date
Martin Atkins
7887810587 specsuite: Fix some regressions
Lately we've made some changes that have affected the behavior of the
specsuite tests, causing them to fail. Much of this was caused by changes
to the harness itself (based on hcldec), although one break in particular
here was an intentional change to the implementation of modulo in
upstream cty to make it produce a more accurate result when used with
a fractional divisor.
2021-02-23 09:05:19 -08:00
Martin Atkins
2eaeb36cb3 Use Unicode 13 text segmentation rules
HCL uses a number of upstream libraries that implement algorithms defined
in Unicode. This commit is updating those libraries all to versions that
have Unicode 13 support.

The main implication of this for HCL directly is that when it returns
column numbers in source locations it will count characters using the
Unicode 13 definition of "character", which includes various new
multi-codeunit characters added in Unicode 13.

These new version dependencies will also make Unicode 13 support available
for other functionality that HCL callers might use, such as the stdlib
functions in upstream cty, even though HCL itself does not directly use
those.
2021-02-23 09:05:19 -08:00
James Bardin
2520246c49
Merge pull request #444 from hashicorp/jbardin/hcltest-expr-map
add an ExprMap method to the mock expression
2021-02-08 16:16:39 -05:00
James Bardin
94baef9aa6 add an ExprMap method to the mock expression
Add an ExprMethod so that the mock expressions can be handled by the
hcl.ExprMap function.

Added basic tests for both ExprList and ExprMap
2021-02-08 15:52:16 -05:00
Alisdair McDiarmid
41e40821a6
Update CHANGELOG.md 2021-01-06 09:43:58 -05:00
Alisdair McDiarmid
6eb7705df8 Fix merge
An incompatibility between #440 and #438 was not caught until after
merging both to the main branch.
2021-01-06 09:34:54 -05:00
Pam Selle
0cdbaf8bd0
Update CHANGELOG.md 2021-01-05 16:13:42 -05:00
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
29a3c5edf7
Update CHANGELOG.md 2021-01-05 08:56:59 -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
Alisdair McDiarmid
088f7afb7d
Merge pull request #437 from hashicorp/alisdair/template-join-expr-marked
hclsyntax: Fix panic for marked template loops
2021-01-05 08:54:53 -05:00
Alisdair McDiarmid
8aa03bfcab
Merge pull request #436 from hashicorp/alisdair/splat-marked-collection
hclsyntax: Fix panic for marked collection splat
2021-01-05 08:54:44 -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
f2f7dd7632 hclsyntax: Fix another template loop panic
If individual template expressions in a loop have marks, merge those
marks into the final result when joining.
2020-12-18 14:36:38 -05:00
Alisdair McDiarmid
9e21ad5861 Test splat of collection including marked elements 2020-12-18 14:30:01 -05:00
Alisdair McDiarmid
d74545cb03 hclsyntax: Fix panic for marked template loops 2020-12-18 13:47:47 -05:00
Alisdair McDiarmid
7f17fe4202 hclsyntax: Fix panic for marked collection splat 2020-12-18 13:27:49 -05:00
Alisdair McDiarmid
94940f55d6
Update CHANGELOG.md 2020-12-17 13:03:56 -05:00
Pam Selle
56e58b631f
Update CHANGELOG.md 2020-12-17 10:36:55 -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
baa494e4a8
Merge pull request #434 from hashicorp/pselle/marked-keys
Error if attempting to use marked value as key
2020-12-17 10:33:49 -05:00
Michele Degges
466c0d9ba2
Add win tests to CircleCI; Remove Appveyor (#435)
Add win tests to CircleCI; Remove Appveyor
2020-12-16 12:09:42 -08: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
8045083719
Update CHANGELOG.md 2020-12-10 12:43:59 -05:00
Alisdair McDiarmid
c30c0c40c6
Merge pull request #429 from hashicorp/alisdair/argument-expansion-marks
hclsyntax: Fix panic when expanding marked funargs
2020-12-10 12:43:02 -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
d8c5050248
Prep changelog for next release 2020-12-07 14:38:35 -05:00
Pam Selle
3231752c37
Prep changelog for release 2020-12-07 14:35:50 -05:00
Pam Selle
e97f5e1a86
Update CHANGELOG.md 2020-12-03 12:23:37 -05:00
Pam Selle
42b83d915c
Merge pull request #427 from hashicorp/pselle/marked-conditionals
Unmark conditional values before checking their truthiness
2020-12-03 12:22:02 -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
Martin Atkins
cef803d9d2
Update CHANGELOG.md 2020-12-02 16:11:46 -08:00
Varun Sivapalan
61e260fbae
hclwrite: do not add space after a boolean NOT operator 2020-12-02 16:10:12 -08:00
Martin Atkins
6a747c8a53
Update CHANGELOG.md 2020-12-02 12:11:29 -08:00
Martin Atkins
f1f3985230 hclsyntax: Explicit AST node for parentheses
So far the expression parentheses syntax has been handled entirely in the
parser and has been totally invisible in the AST. That's fine for typical
expression evaluation, but over the years it's led to a few quirky
behaviors in less common situations where we've assumed that all
expressions are covered by the AST itself or by the source ranges that the
AST captures.

In particular, hclwrite assumes that all expressions will have source
ranges that cover their tokens, and it generates an incorrect physical
syntax tree when the AST doesn't uphold that.

After resisting through a few other similar bugs, this commit finally
introduces an explicit AST node for parentheses, which makes the
parentheses explicit in the AST and captures the larger source range that
includes the TokenOParen and the TokenCParen.

This means that parentheses will now be visible as a distinct node when
walking the AST, as reflected in the updated tests here. That may cause
downstream applications that traverse the tree to exhibit different
behaviors but we're not considering that as a "breaking change" because
the Walk function doesn't make any guarantees about the specific AST
shape.
2020-12-02 12:03:00 -08:00
Alisdair McDiarmid
d510cb0326
Prepare changelog for upcoming release 2020-11-30 11:23:54 -05:00
Alisdair McDiarmid
f10222b9d7
Update changelog for v2.7.2 release 2020-11-30 11:20:07 -05:00
Alisdair McDiarmid
2aa4aecdba
Merge pull request #424 from hashicorp/alisdair/fix-panic-traversing-marked-list
Fix panic traversing marked list
2020-11-30 11:08:39 -05:00
Alisdair McDiarmid
d0cb134fec Fix panic traversing marked list
We need to unmark the result of HasIndex in order to compare it with
true or false without a panic.
2020-11-26 10:59:16 -05:00
Alisdair McDiarmid
3bb0644ad8
Update CHANGELOG.md 2020-11-19 11:37:33 -05:00
Alisdair McDiarmid
7e77010ee3
Merge pull request #335 from kinvolk/fix-slice-value-decoding
gohcl/decode.go: fix decoding value slices
2020-11-19 11:35:55 -05:00
Martin Atkins
819c383cfb
Update CHANGELOG.md 2020-11-18 14:29:01 -08: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
9dabf7d816
Prepare changelog for next release 2020-11-18 11:54:22 -05:00
Alisdair McDiarmid
eadfd40eca
Update CHANGELOG.md 2020-11-18 11:53:03 -05:00
Alisdair McDiarmid
253a71d65c
Merge pull request #422 from hashicorp/alisdair/hclwrite-empty-labels
hclwrite: Allow blank quoted string block labels
2020-11-18 11:50:06 -05:00
Alisdair McDiarmid
1818f36094 hclwrite: Allow blank quoted string block labels
The hclsyntax package permits block labels to be blank quoted strings,
and defers to the application to determine if this is valid or not. This
commit updates hclwrite to allow the same behaviour.

This is in response to an upstream bug report on Terraform, which uses
hclwrite to implement its fmt subcommand. Given a block with a blank
quoted string label, it currently deletes the label when formatting.
This is inconsistent with Terraform's behaviour when parsing HCL, which
treats empty labels differently from missing labels.
2020-11-18 09:21:23 -05:00
Mitchell Hashimoto
3de61ecba2
Merge pull request #412 from hashicorp/mitchellh/body
"body" struct tag to capture entire body for a block decode
2020-10-22 17:07:45 -07:00