Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong NameRange for namespaced function call expressions #650

Closed
Tracked by #1674
dbanck opened this issue Jan 22, 2024 · 0 comments · Fixed by #651
Closed
Tracked by #1674

Wrong NameRange for namespaced function call expressions #650

dbanck opened this issue Jan 22, 2024 · 0 comments · Fixed by #651
Assignees

Comments

@dbanck
Copy link
Member

dbanck commented Jan 22, 2024

#639 introduced namespaced functions. While exploring what's required to support this in terraform-ls, I discovered that the NameRange for function call expressions with the new syntax seems to be off.

Test Code

package main

import (
	"log"

	"github.com/hashicorp/hcl/v2"
	"github.com/hashicorp/hcl/v2/hclsyntax"
)

func main() {
	cfg := `attr = test::noop("noop")`
	f, _ := hclsyntax.ParseConfig([]byte(cfg), "", hcl.InitialPos)
	attrs, _ := f.Body.JustAttributes()
	expr := attrs["attr"].Expr.(*hclsyntax.FunctionCallExpr)
	log.Printf("Name Range: %#v", expr.NameRange)
}

Output

Name Range: hcl.Range{Filename:"", Start:hcl.Pos{Line:1, Column:8, Byte:7}, End:hcl.Pos{Line:1, Column:12, Byte:11}}

Thus, the name range contains only the first part of a namespaced function call, rather than the entire expression up to the opening parenthesis.

attr = test::noop("noop")
       ^^^^ NameRange
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants