This new test is covering a syntax error case that we were previously not handling gracefully. The change is actually in the HCL2 repository, to make this return a non-nil empty body in the case of a syntax error, but since this codebase is relying on that we'll test it up here too, to reduce the risk of this inadvertently regressing in future.
A convention in HCL2 is that functions which return diagnostics should return a "best effort" valid-but-possibly-incomplete object when returning errors, since this then allows some careful analysis of the partial object to generate a more complete set of errors. We don't return nil bodies in any other case, so it's best here to return an empty one to meet the "valid-but-incomplete" requirement.
This new test is covering a syntax error case that we were previously not handling gracefully. The change is actually in the HCL2 repository, to make this return a non-nil empty body in the case of a syntax error, but since this codebase is relying on that we'll test it up here too, to reduce the risk of this inadvertently regressing in future.
A convention in HCL2 is that functions which return diagnostics should return a "best effort" valid-but-possibly-incomplete object when returning errors, since this then allows some careful analysis of the partial object to generate a more complete set of errors. We don't return nil bodies in any other case, so it's best here to return an empty one to meet the "valid-but-incomplete" requirement.