diff options
| author | Ansgar Mertens <ansgar@hashicorp.com> | 2024-02-09 14:26:37 +0100 |
|---|---|---|
| committer | Ansgar Mertens <ansgar@hashicorp.com> | 2024-02-09 14:26:37 +0100 |
| commit | e1cf84daaa73a8c94605c595ad97dda832efa74f (patch) | |
| tree | 9605a9e4838ab54f697ee0551a343d7db279ced9 /hclsyntax/parser_test.go | |
| parent | c964a71ca32006c9e7a0730b5a0e1dd60b05d308 (diff) | |
fix: fix NameRange for namespaced functions
Resolves #650
Diffstat (limited to 'hclsyntax/parser_test.go')
| -rw-r--r-- | hclsyntax/parser_test.go | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/hclsyntax/parser_test.go b/hclsyntax/parser_test.go index 69636c9..236daa0 100644 --- a/hclsyntax/parser_test.go +++ b/hclsyntax/parser_test.go @@ -2462,6 +2462,103 @@ block "valid" {} }, }, }, + { + "a = a::namespaced::func(data.first.ref.attr)\n", + 0, + &Body{ + Attributes: Attributes{ + "a": { + Name: "a", + Expr: &FunctionCallExpr{ + Name: "a::namespaced::func", + Args: []Expression{ + &ScopeTraversalExpr{ + Traversal: hcl.Traversal{ + hcl.TraverseRoot{ + Name: "data", + SrcRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 25, Byte: 24}, + End: hcl.Pos{Line: 1, Column: 29, Byte: 28}, + }, + }, + hcl.TraverseAttr{ + Name: "first", + SrcRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 29, Byte: 28}, + End: hcl.Pos{Line: 1, Column: 35, Byte: 34}, + }, + }, + hcl.TraverseAttr{ + Name: "ref", + SrcRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 35, Byte: 34}, + End: hcl.Pos{Line: 1, Column: 39, Byte: 38}, + }, + }, + hcl.TraverseAttr{ + Name: "attr", + SrcRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 39, Byte: 38}, + End: hcl.Pos{Line: 1, Column: 44, Byte: 43}, + }, + }, + }, + SrcRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 25, Byte: 24}, + End: hcl.Pos{Line: 1, Column: 44, Byte: 43}, + }, + }, + }, + ExpandFinal: false, + NameRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 5, Byte: 4}, + End: hcl.Pos{Line: 1, Column: 24, Byte: 23}, + }, + OpenParenRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 24, Byte: 23}, + End: hcl.Pos{Line: 1, Column: 25, Byte: 24}, + }, + CloseParenRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 44, Byte: 43}, + End: hcl.Pos{Line: 1, Column: 45, Byte: 44}, + }, + }, + SrcRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 1, Byte: 0}, + End: hcl.Pos{Line: 1, Column: 45, Byte: 44}, + }, + NameRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 1, Byte: 0}, + End: hcl.Pos{Line: 1, Column: 2, Byte: 1}, + }, + EqualsRange: hcl.Range{ + Filename: "", + Start: hcl.Pos{Line: 1, Column: 3, Byte: 2}, + End: hcl.Pos{Line: 1, Column: 4, Byte: 3}, + }, + }, + }, + Blocks: Blocks{}, + SrcRange: hcl.Range{ + Start: hcl.Pos{Line: 1, Column: 1, Byte: 0}, + End: hcl.Pos{Line: 2, Column: 1, Byte: 45}, + }, + EndRange: hcl.Range{ + Start: hcl.Pos{Line: 2, Column: 1, Byte: 45}, + End: hcl.Pos{Line: 2, Column: 1, Byte: 45}, + }, + }, + }, } for _, test := range tests { |
