Parsed `hclsyntax.Body` has slightly different range depending on what type of comment is at the top
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 657
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 6
Description
I would expect this to print the same thing six times but the `/**/` seems to behave differently if it's on the first line.
```
false
true
true
true
true
true
```
```Go
package main
import (
"fmt"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsyntax"
)
func containsInitialPos(content string) bool {
file, _ := hclsyntax.ParseConfig([]byte(content), "", hcl.InitialPos)
body, _ := file.Body.(*hclsyntax.Body)
return body.Range().ContainsPos(hcl.InitialPos)
}
func main() {
fmt.Println(containsInitialPos("/**/\ntarget{}"))
fmt.Println(containsInitialPos("#\ntarget{}"))
fmt.Println(containsInitialPos("//\ntarget{}"))
fmt.Println(containsInitialPos("\n/**/\ntarget{}"))
fmt.Println(containsInitialPos("\n#\ntarget{}"))
fmt.Println(containsInitialPos("\n//\ntarget{}"))
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.