hashicorp / hcl2

Former temporary home for experimental new version of HCL
https://github.com/hashicorp/hcl
Mozilla Public License 2.0
374 stars 64 forks source link

Spurious error parsing existing Terraform configuration #11

Closed apparentlymart closed 6 years ago

apparentlymart commented 6 years ago

When asked to parse a file from Terraform's public module registry, the HCL native syntax parser produced the following error:

Error: Missing newline after attribute definition at main.tf:104,3

An attribute definition must end with a newline.

This message seems to be a parsing bug, since line 104 is the following valid attribute definition:

  availability_zone       = "${element(var.azs, count.index)}"

It's referring to column 3 here, which is the location of the availability_zone identifier. Possibly there's some leftover state bleeding through from the previous line, causing the parser to get confused when it encounters the next token. Previous line is:

 cidr_block              = "${var.public_subnets[count.index]}"

(This also appears to be valid.)

apparentlymart commented 6 years ago

Based on some local testing it seems like indeed the bug being triggered by the cidr_block line, since this error appears any time there's another attribute or block after it, regardless of what attribute or block it is.

apparentlymart commented 6 years ago

This was fixed in 9dfc220a4b5ca43caf94b781b55fdf9b97bcad72.