hashicorp / hashicorp/hcl

Empty block syntactic sugar

Open
#288 1 comment 3 reactions 0 assignees View on GitHub
enhancement syntax/native v2
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

Hi,

I've noticed that often configuration files contain empty blocks, for example:

```
variable "prod_access_key" {}
variable "prod_secret_key" {}
variable "test_account_id" {}
variable "test_access_key" {}
variable "test_secret_key" {}
variable "bucket_name" {}
```
taken from: https://github.com/terraform-providers/terraform-provider-aws/blob/24e937a299c9115be47052404a97d6c9d5a4ccfa/examples/s3-cross-account-access/variables.tf.

Have you considered in HCL2 allowing shorter form without explicit mention the empty block? For example:
```
variable "prod_access_key"
variable "prod_secret_key"
variable "test_account_id"
variable "test_access_key"
variable "test_secret_key"
variable "bucket_name"
```

Thanks!
Hadar

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the HCL2 block syntax and the referenced examples/s3-cross-account-access/variables.tf configuration to understand current empty-block usage. Determine whether bare two-label declarations should be accepted, then define the syntax and compatibility behavior before adding parser coverage; done means the proposal has an agreed design and passing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.