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.
This commit is contained in:
Antti Kupila 2019-04-18 16:30:39 +02:00 committed by Martin Atkins
parent 2c5a4b7d72
commit f7764c6954

View File

@ -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(),
})
}