hashicorp / hashicorp/hcl

Unable to use HCL identifiers with "`.`" in function call in block attribute

Open
#579 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
5.8k
Forks
659
Avg merge
20h 36m
Merged PRs (30d)
6

Description

While investigating the following syntax:

example "something arbitrary" {
   result = repository.file("main.go").example
}

I ran into the following error parsing it:

Error: Missing newline after argument

  on issue.hcl line 2, in example "something arbitrary":
   2:    result = repository.file("main.go").example

An argument definition must end with a newline.

issue.hcl:2,28-29: Missing newline after argument; An argument definition must end with a newline.

Seems related to this line in (*hclsyntax.parser).finishParsingBodyAttribute:

https://github.com/hashicorp/hcl/blob/67270baea3ce5e9c56470c3bfc505ca4e2c2de8c/hclsyntax/parser.go#L260

Based on my reading of the spec's "function call" and "identifier" definitions, this seems like it could be possible, but currently ins't implemented? Or is this something that isn't allowed purposefully? It's not clear to me how traversals should work in this case.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in hclsyntax/parser.go at (*hclsyntax.parser).finishParsingBodyAttribute and inspect how function calls, identifiers, and traversals are parsed. Compare that behavior with the function call and identifier rules in the HCL specification, then establish whether the example syntax should parse and capture the expected result in parser coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.