hcl/parser: support bools in lists
This commit is contained in:
parent
eb6f65b2d7
commit
e59762bcc7
@ -391,6 +391,23 @@ func TestDecode_interface(t *testing.T) {
|
||||
true,
|
||||
nil,
|
||||
},
|
||||
|
||||
{
|
||||
"object_with_bool.hcl",
|
||||
false,
|
||||
map[string]interface{}{
|
||||
"path": []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"policy": "write",
|
||||
"permissions": []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"bool": []interface{}{false},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
@ -346,7 +346,7 @@ func (p *Parser) listType() (*ast.ListType, error) {
|
||||
}
|
||||
}
|
||||
switch tok.Type {
|
||||
case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
|
||||
case token.BOOL, token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
|
||||
node, err := p.literalType()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -388,8 +388,6 @@ func (p *Parser) listType() (*ast.ListType, error) {
|
||||
}
|
||||
l.Add(node)
|
||||
needComma = true
|
||||
case token.BOOL:
|
||||
// TODO(arslan) should we support? not supported by HCL yet
|
||||
case token.LBRACK:
|
||||
// TODO(arslan) should we support nested lists? Even though it's
|
||||
// written in README of HCL, it's not a part of the grammar
|
||||
|
@ -58,6 +58,10 @@ func TestListType(t *testing.T) {
|
||||
`foo = [123, "123",]`,
|
||||
[]token.Type{token.NUMBER, token.STRING},
|
||||
},
|
||||
{
|
||||
`foo = [false]`,
|
||||
[]token.Type{token.BOOL},
|
||||
},
|
||||
{
|
||||
`foo = []`,
|
||||
[]token.Type{},
|
||||
|
6
test-fixtures/object_with_bool.hcl
Normal file
6
test-fixtures/object_with_bool.hcl
Normal file
@ -0,0 +1,6 @@
|
||||
path {
|
||||
policy = "write"
|
||||
permissions = {
|
||||
"bool" = [false]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user