Merge pull request #76 from hashicorp/phinze/fix-missing-braces-crash
Fix crash on missing braces
This commit is contained in:
commit
5af5025c48
@ -151,7 +151,7 @@ func (p *Parser) objectItem() (*ast.ObjectItem, error) {
|
|||||||
|
|
||||||
// do a look-ahead for line comment
|
// do a look-ahead for line comment
|
||||||
p.scan()
|
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
|
o.LineComment = p.lineComment
|
||||||
p.lineComment = nil
|
p.lineComment = nil
|
||||||
}
|
}
|
||||||
|
@ -292,6 +292,10 @@ func TestParse(t *testing.T) {
|
|||||||
"array_comment_2.hcl",
|
"array_comment_2.hcl",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"missing_braces.hcl",
|
||||||
|
true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const fixtureDir = "./test-fixtures"
|
const fixtureDir = "./test-fixtures"
|
||||||
|
4
hcl/parser/test-fixtures/missing_braces.hcl
Normal file
4
hcl/parser/test-fixtures/missing_braces.hcl
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# should error, but not crash
|
||||||
|
resource "template_file" "cloud_config" {
|
||||||
|
template = "$file("${path.module}/some/path")"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user