mirror of https://github.com/hashicorp/terraform
This includes a small fix to ensure the parser doesn't produce an invalid body for block parsing syntax errors, and instead produces an incomplete result that calling applications like Terraform can still analyze. The problem here was affecting our version-constraint-sniffing code, which intentionally tried to find a core version constraint even if there's a syntax error so that it can report that a new version of Terraform is a likely cause of the syntax error. It was working in most cases, unless it was the "terraform" block itself that contained the error, because then we'd try to analyze a broken hcl.Block with a nil body. This includes a new test for "terraform init" that exercises this recovery codepath.pull/21310/head
parent
e0cec2075e
commit
63fa1ac418
@ -0,0 +1,9 @@
|
||||
# The following is invalid because we don't permit multiple nested blocks
|
||||
# all one one line. Instead, we require the backend block to be on a line
|
||||
# of its own.
|
||||
# The purpose of this test case is to see that HCL still produces a valid-enough
|
||||
# AST that we can try to sniff in this block for a terraform_version argument
|
||||
# without crashing, since we do that during init to try to give a better
|
||||
# error message if we detect that the configuration is for a newer Terraform
|
||||
# version.
|
||||
terraform { backend "local" {} }
|
||||
Loading…
Reference in new issue