Support HEREDOCs in lists

This fixes a regression in Terraform where HEREDOCS were previously
supported in lists, reported in hashicorp/terraform#4065.
This commit is contained in:
James Nugent 2015-11-26 14:52:16 +02:00
parent 692d016087
commit eb77c8f861
2 changed files with 10 additions and 1 deletions

View File

@ -264,7 +264,7 @@ func (p *Parser) listType() (*ast.ListType, error) {
for {
tok := p.scan()
switch tok.Type {
case token.NUMBER, token.FLOAT, token.STRING:
case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
if needComma {
return nil, &PosError{
Pos: tok.Pos,

View File

@ -64,6 +64,15 @@ func TestListType(t *testing.T) {
`foo = ["123", 123]`,
[]token.Type{token.STRING, token.NUMBER},
},
{
`foo = [1,
"string",
<<EOF
heredoc contents
EOF
]`,
[]token.Type{token.NUMBER, token.STRING, token.HEREDOC},
},
}
for _, l := range literals {