From 504b92060753616a7b06cf65b540c23170f064e1 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 13 Feb 2019 17:14:54 -0800 Subject: [PATCH] hclsyntax: Fix error diagnostic for blocks inside JustAttributes The range was incorrectly being reported as "Context", rather than "Subject". The Context field has meaning only in conjunction with Subject. While here, this also tweaks the summary to show the block type name in quotes, since otherwise the sentence can read oddly for certain block type names. --- hcl/hclsyntax/structure.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hcl/hclsyntax/structure.go b/hcl/hclsyntax/structure.go index ebafcb4..22e389c 100644 --- a/hcl/hclsyntax/structure.go +++ b/hcl/hclsyntax/structure.go @@ -255,9 +255,9 @@ func (b *Body) JustAttributes() (hcl.Attributes, hcl.Diagnostics) { example := b.Blocks[0] diags = append(diags, &hcl.Diagnostic{ Severity: hcl.DiagError, - Summary: fmt.Sprintf("Unexpected %s block", example.Type), + Summary: fmt.Sprintf("Unexpected %q block", example.Type), Detail: "Blocks are not allowed here.", - Context: &example.TypeRange, + Subject: &example.TypeRange, }) // we will continue processing anyway, and return the attributes // we are able to find so that certain analyses can still be done