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:
parent
692d016087
commit
eb77c8f861
@ -264,7 +264,7 @@ func (p *Parser) listType() (*ast.ListType, error) {
|
|||||||
for {
|
for {
|
||||||
tok := p.scan()
|
tok := p.scan()
|
||||||
switch tok.Type {
|
switch tok.Type {
|
||||||
case token.NUMBER, token.FLOAT, token.STRING:
|
case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
|
||||||
if needComma {
|
if needComma {
|
||||||
return nil, &PosError{
|
return nil, &PosError{
|
||||||
Pos: tok.Pos,
|
Pos: tok.Pos,
|
||||||
|
@ -64,6 +64,15 @@ func TestListType(t *testing.T) {
|
|||||||
`foo = ["123", 123]`,
|
`foo = ["123", 123]`,
|
||||||
[]token.Type{token.STRING, token.NUMBER},
|
[]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 {
|
for _, l := range literals {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user