hcl/hcl
Martin Atkins 0b64543c96 hclsyntax: Parse indexing brackets with a string literal as a traversal
A sequence like "foo" is represented in the AST as a TemplateExpr with a
single string literal inside rather than as a string literal node
directly, so we need to recognize that situation during parsing and treat
it as a special case so we can get the intended behavior of representing
that index as a traversal step rather than as a dynamic index operation.

Most of the time this distinction doesn't matter, but it's important for
static analysis use-cases. In particular, hcl.AbsTraversalForExpr will now
accept an expression like foo["bar"] where before it would've rejected it.

This also includes a better error message for when an expression cannot be
recognized as a single traversal. There isn't really any context here to
return a direct reference to the construct that was problematic, which is
what we'd ideally do, but at least this new message includes a summary
of what is allowed and some examples of things that are not allowed as an
aid to understanding what "static variable reference" means.
2019-06-18 09:38:56 -07:00
..
hclsyntax hclsyntax: Parse indexing brackets with a string literal as a traversal 2019-06-18 09:38:56 -07:00
integrationtest hclsyntax: "null", "true", "false" AbsTraversalForExpr 2018-02-26 08:38:35 -08:00
json return array value evaluation diagnostics (#113) 2019-06-17 12:00:22 -04:00
spectests hcl/spectests: run the spec testsuite as part of "go test" 2018-08-12 18:22:10 -07:00
diagnostic_text_test.go hcl: Include variable values in rendered diagnostics messages 2018-07-28 14:42:53 -07:00
diagnostic_text.go hcl: Deduplicate symbols when printing diagnostic messages 2018-07-28 15:44:15 -07:00
diagnostic.go hcl: Include Expression reference in diagnostics 2018-07-28 13:36:55 -07:00
didyoumean.go Move the zcl package and its two parsing subpackages to "hcl" names 2017-09-11 16:40:37 -07:00
doc.go Move the zcl package and its two parsing subpackages to "hcl" names 2017-09-11 16:40:37 -07:00
eval_context.go Move the zcl package and its two parsing subpackages to "hcl" names 2017-09-11 16:40:37 -07:00
expr_call.go hcl: ExprCall function 2018-03-04 14:04:54 -08:00
expr_list.go hcl: UnwrapExpression and UnwrapExpressionUntil 2018-01-27 09:10:18 -08:00
expr_map.go hcl: ExprMap function 2018-02-23 08:41:58 -08:00
expr_unwrap.go hcl: UnwrapExpression and UnwrapExpressionUntil 2018-01-27 09:10:18 -08:00
merged_test.go go fmt updates 2018-12-11 16:49:03 -08:00
merged.go hcl: Fix PartialContent used on MergeBody result 2018-12-11 15:23:12 -08:00
ops_test.go hcl: Special error message for indexing a sequence with a fraction 2019-04-16 09:23:32 -07:00
ops.go hcl: Special error message for indexing a sequence with a fraction 2019-04-16 09:23:32 -07:00
pos_scanner_test.go hcl: RangeScanner helper 2018-01-14 11:24:19 -08:00
pos_scanner.go hcl: NewRangeScannerFragment function 2019-04-12 15:16:41 -07:00
pos_test.go hcl: SourceRange.PartitionAround 2018-01-14 11:51:05 -08:00
pos.go hcl: NewRangeScannerFragment function 2019-04-12 15:16:41 -07:00
schema.go Move the zcl package and its two parsing subpackages to "hcl" names 2017-09-11 16:40:37 -07:00
spec.md Normalize the spec markdown styles 2019-01-03 08:46:02 -08:00
static_expr.go hcl: StaticExpr function for making synthetic expressions 2017-09-20 16:22:05 -07:00
structure_at_pos.go hcl: Best-effort "what's at this position" helpers 2018-07-28 13:17:51 -07:00
structure.go More miscellaneous renaming of ZCL to HCL. 2017-09-11 18:36:56 -07:00
traversal_for_expr_test.go hcl: ExprAsKeyword function 2018-02-03 08:55:50 -08:00
traversal_for_expr.go hclsyntax: Parse indexing brackets with a string literal as a traversal 2019-06-18 09:38:56 -07:00
traversal.go hcl: New GetAttr and ApplyPath functions 2019-01-30 14:52:18 -08:00