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

Incorrect range for FunctionCallExpr w/ incomplete ObjectConsExpr inside #582

Closed
radeksimko opened this issue Jan 24, 2023 · 0 comments · Fixed by #588
Closed

Incorrect range for FunctionCallExpr w/ incomplete ObjectConsExpr inside #582

radeksimko opened this issue Jan 24, 2023 · 0 comments · Fixed by #588
Labels

Comments

@radeksimko
Copy link
Member

radeksimko commented Jan 24, 2023

As can be demonstrated by the following snippet, there seems to be disparity in reporting of the range for the function call when there's an incomplete ObjectConsExpr (or probably any other incomplete argument) inside.

package main

import (
	"fmt"

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

func main() {
	src := []byte(`foo({test = })`)
	expr, _ := hclsyntax.ParseExpression(src, "test.hcl", hcl.InitialPos)
	fmt.Printf("inside function: %#v\n", expr.Range())
}
hcl.Range{
	Filename:"test.hcl",
	Start:hcl.Pos{Line:1, Column:1, Byte:0},
	End:hcl.Pos{Line:0, Column:0, Byte:0},
}

The reason this is important is because it makes it difficult to enable completion in language server for attribute values (i.e. on the RHS), as it is hard to tell where exactly a given position is.

I am aware that there is probably number of other cases where incomplete configuration is parsed in unexpected ways, but the main reason I'm raising this is because of the disparity between two very similar cases.

@radeksimko radeksimko added the bug label Jan 24, 2023
@radeksimko radeksimko changed the title Incorrect range for incomplete ObjectConsExpr in FunctionCallExpr Incorrect range for FunctionCallExpr w/ incomplete ObjectConsExpr inside Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant