hclsyntax: If nested block doesn't parse, produce empty body
Our usual rule for parse errors is to return a valid-but-incomplete object along with error diagnostics. This was violating that rule by returning a nil child body, which callers do not expect to deal with. Instead, we'll return an *empty* body, so that callers who use the partial result for careful analyses can still process the block header, without needing to guard against the body being nil.
This commit is contained in:
parent
cce5ae6cc5
commit
3e4b7e0eb2
@ -273,7 +273,10 @@ Token:
|
||||
return &Block{
|
||||
Type: blockType,
|
||||
Labels: labels,
|
||||
Body: nil,
|
||||
Body: &Body{
|
||||
SrcRange: ident.Range,
|
||||
EndRange: ident.Range,
|
||||
},
|
||||
|
||||
TypeRange: ident.Range,
|
||||
LabelRanges: labelRanges,
|
||||
|
Loading…
Reference in New Issue
Block a user