From f7764c69544d29058a63afc2b44ed3d4168a7608 Mon Sep 17 00:00:00 2001 From: Antti Kupila Date: Thu, 18 Apr 2019 16:30:39 +0200 Subject: [PATCH] hclpack: Fix name range for unsupported attribute Fixes an issue where the name range may be incorrect in case there are multiple attributes and one of them is wrong. Another attribute's name range could overwrite the previous one as the attr variable is overwritten in the for loop. --- hclpack/structure.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hclpack/structure.go b/hclpack/structure.go index 4c72be5..488a99e 100644 --- a/hclpack/structure.go +++ b/hclpack/structure.go @@ -101,11 +101,12 @@ func (b *Body) content(schema *hcl.BodySchema, remain *Body) (*hcl.BodyContent, } } } + diags = append(diags, &hcl.Diagnostic{ Severity: hcl.DiagError, Summary: "Unsupported argument", Detail: fmt.Sprintf("An argument named %q is not expected here.%s", name, suggestion), - Subject: &attr.NameRange, + Subject: attr.NameRange.Ptr(), }) }