Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow empty value in list. #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,10 @@ func (p *parser) parse(isRoot bool) (result []*ast.Node, endPos ast.Position, er
return nil, ast.Position{}, err
}
if len(vals) != 1 {
return nil, ast.Position{}, fmt.Errorf("multiple-string value not supported (%v). Please add comma explcitily, see http://b/162070952", vals)
return nil, ast.Position{}, fmt.Errorf("multiple-string value not supported (%v). Please add comma explicitly, see http://b/162070952", vals)
}
if len(vals[0].Value) == 0 {
return nil, ast.Position{}, fmt.Errorf("empty value in list")
}
vals[0].PreComments = append(vals[0].PreComments, preComments...)

Expand Down
2 changes: 2 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func TestError(t *testing.T) {
}, {
in: `name: "string with literal new line
"`, err: "new line",
}, {
in: `list_with_empty_list: [a,,b]`, err: "empty value in list",
}}
for _, input := range inputs {
out, err := Format([]byte(input.in))
Expand Down