Provide accurate constraints in index part of references #1596
Labels
diagnostics
enhancement
New feature or request
textDocument/completion
textDocument/hover
textDocument/publishDiagnostics
Follow-up from hashicorp/hcl-lang#365 (comment)
Context
Currently we recognise index expression such as
var.foo[var.bar]
, in the sense that we provide:While this is helpful, we currently treat all
[]
(indexes) in references as if they were a map, i.e. something indexable with keys of type string.https://github.com/hashicorp/hcl-lang/blob/f43c27231c1001f4682f6fe72011cdabe692bdef/decoder/expr_any_index.go#L19-L25
Because we check for type convertability and strings/numbers are convertible in cty, this does not impact the functionality in a major way. However, it can make it less helpful in some contexts.
var.map[var.number]
orvar.list[var.string]
)Proposal
[]
are inferred from the type of the referencevar.map[var.number]
orvar.list[var.string]
The text was updated successfully, but these errors were encountered: