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:
parent
2c5a4b7d72
commit
f7764c6954
@ -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(),
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user