hclsyntax: Recovery of incomplete `ConditionalExpr`
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 657
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 6
Description
## Background
Similar to some earlier issues, we found some more edge cases while implementing support for `ConditionalExpr` in the Language Server.
https://github.com/hashicorp/hcl-lang/pull/326
- incomplete `ConditionalExpr`
- `attr = ? var.foo : var.bar`
- `attr = var.foo ? : var.bar`
- `attr = var.foo ? var.bar :`
- `attr = var.foo ? `
- "impeding" incomplete `Traversal` (with trailing dot) inside otherwise complete `ConditionalExpr`
- `attr = var. ? var.foo : var.bar`
- `attr = var.foo ? var. : var.bar`
- `attr = var.foo ? var.bar : var.`
As with other reports related to recovery from incomplete configuration, the context is - again - enabling completion. Users would reasonably expect to be offered relevant completion in the above contexts, because it is exactly the nature of _completion_ to _complete_ the _incomplete_ configuration.
## Proposal
Regarding the incomplete `Traversal` specifically - I remember seeing other contexts where the trailing dot is simply ignored and the outer expression is recovered and so is the attribute as whole. I am therefore a little more hopeful we could do something about these edge cases.
The other ones like `attr = ? var.foo : var.bar` I would think could still be reported as `ConditionalExpr` but with either `nil` or some kind of empty expressions (I've seen `LiteralValueExpr{}` used before in similar contexts, such as `attr =`).
The only incomplete expression I can see being really difficult or maybe impossible to deal with meaningfully is the one which is missing a control character `:` (`attr = var.foo ? `) because there could be lack of confidence in what kind of expression is it even supposed to be.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.