Merge pull request #76 from hashicorp/phinze/fix-missing-braces-crash

Fix crash on missing braces
This commit is contained in:
Paul Hinze 2015-12-16 18:36:51 -06:00
commit 5af5025c48
3 changed files with 9 additions and 1 deletions

View File

@ -151,7 +151,7 @@ func (p *Parser) objectItem() (*ast.ObjectItem, error) {
// do a look-ahead for line comment
p.scan()
if o.Val.Pos().Line == keys[0].Pos().Line && p.lineComment != nil {
if len(keys) > 0 && o.Val.Pos().Line == keys[0].Pos().Line && p.lineComment != nil {
o.LineComment = p.lineComment
p.lineComment = nil
}

View File

@ -292,6 +292,10 @@ func TestParse(t *testing.T) {
"array_comment_2.hcl",
true,
},
{
"missing_braces.hcl",
true,
},
}
const fixtureDir = "./test-fixtures"

View File

@ -0,0 +1,4 @@
# should error, but not crash
resource "template_file" "cloud_config" {
template = "$file("${path.module}/some/path")"
}