- hclsyntax: Evaluation of conditional expressions will now produce more precise error messages about inconsistencies between the types of the true and false result expressions, particularly in cases where both are of the same structural type kind but differ in their nested elements. (#530)
- hclsyntax: The lexer will no longer allocate a small object on the heap for each token. Instead, in that situation it will allocate only when needed to return a diagnostic message with source location information. (#490)
- hclwrite: New functions
TokensForTuple
,TokensForObject
, andTokensForFunctionCall
allow for more easily constructing the three constructs which are supported for static analysis and which HCL-based languages typically use in contexts where an expression is used only for its syntax, and not evaluated to produce a real value. For example, these new functions together are sufficient to construct all valid type constraint expressions from the Type Expressions Extension, which is the basis of variable type constraints in the Terraform language at the time of writing. (#502)
- gohcl: Fix docs about supported types for blocks. (#507)
- hclsyntax: The type for an upgraded unknown value with a splat expression cannot be known (#495)
- hclsyntax: Various error messages related to unexpectedly reaching end of file while parsing a delimited subtree will now return specialized messages describing the opening tokens as "unclosed", instead of returning a generic diagnostic that just happens to refer to the empty source range at the end of the file. This gives better feedback when error messages are being presented alongside a source code snippet, as is common in HCL-based applications, because it shows which innermost container the parser was working on when it encountered the error. (#492)
- hclsyntax: Upgrading an unknown single value to a list using a splat expression must return unknown (#493)
- dynblock: Decode unknown dynamic blocks in order to obtain any diagnostics even though the decoded value is not used (#476)
- hclsyntax: Calling functions is now more robust in the face of an incorrectly-implemented function which returns a
function.ArgError
whose argument index is out of range for the length of the arguments. Previously this would often lead to a panic, but now it'll return a less-precice error message instead. Functions that return out-of-bounds argument indices still ought to be fixed so that the resulting error diagnostics can be as precise as possible. (#472) - hclsyntax: Ensure marks on unknown values are maintained when processing string templates. (#478)
- hcl: Improved error messages for various common error situtions in
hcl.Index
andhcl.GetAttr
. These are part of the implementation of indexing and attribute lookup in the native syntax expression language too, so the new error messages will apply to problems using those operators. (#474)
- dynblock,hcldec: Using dynblock in conjunction with hcldec can now decode blocks with unknown dynamic for_each arguments as entirely unknown values (#461)
- hclsyntax: Some syntax errors during parsing of the inside of
${
...}
template interpolation sequences will now produce an extra hint message about the need to escape as$${
when trying to include interpolation syntax for other languages like shell scripting, AWS IAM policies, etc. (#462)
- hclsyntax: Fix panic for marked index value. (#451)
- HCL's native syntax and JSON scanners -- and thus all of the other parsing components that build on top of them -- are now using Unicode 13 rules for text segmentation when counting text characters for the purpose of reporting source location columns. Previously HCL was using Unicode 12. Unicode 13 still uses the same algorithm but includes some additions to the character tables the algorithm is defined in terms of, to properly categorize new characters defined in Unicode 13.
- hclsyntax: Fix panic for marked collection splat. (#436)
- hclsyntax: Fix panic for marked template loops. (#437)
- hclsyntax: Fix
for
expression marked conditional. (#438) - hclsyntax: Mark objects with keys that are sensitive. (#440)
- hclsyntax: Fix panic when expanding marked function arguments. (#429)
- hclsyntax: Error when attempting to use a marked value as an object key. (#434)
- hclsyntax: Error when attempting to use a marked value as an object key in expressions. (#433)
- hclsyntax: Expression grouping parentheses will now be reflected by an explicit node in the AST, whereas before they were only considered during parsing. (#426)
- hclwrite: The parser will now correctly include the
(
and)
tokens when an expression is surrounded by parentheses. Previously it would incorrectly recognize those tokens as being extraneous tokens outside of the expression. (#426) - hclwrite: The formatter will now remove (rather than insert) spaces between the
!
(unary boolean "not") operator and its subsequent operand. (#403) - hclsyntax: Unmark conditional values in expressions before checking their truthfulness (#427)
- gohcl: Fix panic when decoding into type containing value slices. (#335)
- hclsyntax: The unusual expression
null[*]
was previously always returning an unknown value, even though the rules for[*]
normally call for it to return an empty tuple when applied to a null. As well as being a surprising result, it was particularly problematic because it violated the rule that a calling application may assume that an expression result will always be known unless the application itself introduces unknown values via the evaluation context.null[*]
will now produce an empty tuple. (#416) - hclsyntax: Fix panic when traversing a list, tuple, or map with cty "marks" (#424)
- hclwrite: Correctly handle blank quoted string block labels, instead of dropping them (#422)
- json: There is a new function
ParseWithStartPos
, which allows overriding the starting position for parsing in case the given JSON bytes are a fragment of a larger document, such as might happen when decoding withencoding/json
into ajson.RawMessage
. (#389) - json: There is a new function
ParseExpression
, which allows parsing a JSON string directly in expression mode, whereas previously it was only possible to parse a JSON string in body mode. (#381) - hclwrite:
Block
type now supportsSetType
andSetLabels
, allowing surgical changes to the type and labels of an existing block without having to reconstruct the entire block. (#340)
- hclsyntax: Fix confusing error message for bitwise OR operator (#380)
- hclsyntax: Several bug fixes for using HCL with values containing cty "marks" (#404, #406, #407)
- hcldec: Add a new
Spec
,ValidateSpec
, which allows custom validation of values at decode-time. (#387)
- hclsyntax: Fix panic with combination of sequences and null arguments (#386)
- hclsyntax: Fix handling of unknown values and sequences (#386)
- hclwrite: handle legacy dot access of numeric indexes. (#369)
- hclwrite: Fix panic for dotted full splat (
foo.*
) (#374)
- hclwrite: Generate multi-line objects and maps. (#372)
- The Unicode data tables that HCL uses to produce user-perceived "column" positions in diagnostics and other source ranges are now updated to Unicode 12.0.0, which will cause HCL to produce more accurate column numbers for combining characters introduced to Unicode since Unicode 9.0.0.
- json: Fix panic when parsing malformed JSON. (#358)
- ext/tryfunc: Optional functions
try
andcan
to include in yourhcl.EvalContext
when evaluating expressions, which allow users to make decisions based on the success of expressions. (#330) - ext/typeexpr: Now has an optional function
convert
which you can include in yourhcl.EvalContext
when evaluating expressions, allowing users to convert values to specific type constraints using the type constraint expression syntax. (#330) - ext/typeexpr: A new
cty
capsule typetypeexpr.TypeConstraintType
which, when used as either a type constraint for a function parameter or as a type constraint for ahcldec
attribute specification will cause the given expression to be interpreted as a type constraint expression rather than a value expression. (#330) - ext/customdecode: An optional extension that allows overriding the static decoding behavior for expressions either in function arguments or
hcldec
attribute specifications. (#330) - ext/customdecode: New
cty
capsuletypescustomdecode.ExpressionType
andcustomdecode.ExpressionClosureType
which, when used as either a type constraint for a function parameter or as a type constraint for ahcldec
attribute specification will cause the given expression (and, for the closure type, also thehcl.EvalContext
it was evaluated in) to be captured for later analysis, rather than immediately evaluated. (#330)
- hcldec: Attribute evaluation (as part of
AttrSpec
orBlockAttrsSpec
) now captures expression evaluation metadata in any errors it produces during type conversions, allowing for better feedback in calling applications that are able to make use of this metadata when printing diagnostic messages. (#329)
- hclsyntax:
IndexExpr
,SplatExpr
, andRelativeTraversalExpr
will now report a source range that covers all of their child expression nodes. Previously they would report only the operator part, such as["foo"]
,[*]
, or.foo
, which was problematic for callers using source ranges for code analysis. (#328) - hclwrite: Parser will no longer panic when the input includes index, splat, or relative traversal syntax. (#328)
- gohcl: When decoding into a struct value with some fields already populated, those values will be retained if not explicitly overwritten in the given HCL body, with similar overriding/merging behavior as
json.Unmarshal
in the Go standard library. - hclwrite: New interface to set the expression for an attribute to be a raw token sequence, with no special processing. This has some caveats, so if you intend to use it please refer to the godoc comments. (#320)
- hclwrite: The
Body.Blocks
method was returing the blocks in an indefined order, rather than preserving the order of declaration in the source input. (#313) - hclwrite: The
TokensForTraversal
function (and thus in turn theBody.SetAttributeTraversal
method) was not correctly handling index steps in traversals, and thus producing invalid results. (#319)
Initial release of HCL 2, which is a new implementating combining the HCL 1 language with the HIL expression language to produce a single language supporting both nested configuration structures and arbitrary expressions.
HCL 2 has an entirely new Go library API and so is not a drop-in upgrade relative to HCL 1. It's possible to import both versions of HCL into a single program using Go's semantic import versioning mechanism:
import (
hcl1 "github.com/hashicorp/hcl"
hcl2 "github.com/hashicorp/hcl/v2"
)
Prior to v2.0.0 there was not a curated changelog. Consult the git history from the latest v1.x.x tag for information on the changes to HCL 1.