hcl/parser: fix broken parsing of: "v=/\n[,"
This commit is contained in:
parent
6816a5c3fb
commit
50042432b0
@ -331,7 +331,7 @@ func (p *Parser) listType() (*ast.ListType, error) {
|
|||||||
// get next list item or we are at the end
|
// get next list item or we are at the end
|
||||||
// do a look-ahead for line comment
|
// do a look-ahead for line comment
|
||||||
p.scan()
|
p.scan()
|
||||||
if p.lineComment != nil {
|
if p.lineComment != nil && len(l.List) > 0 {
|
||||||
lit, ok := l.List[len(l.List)-1].(*ast.LiteralType)
|
lit, ok := l.List[len(l.List)-1].(*ast.LiteralType)
|
||||||
if ok {
|
if ok {
|
||||||
lit.LineComment = p.lineComment
|
lit.LineComment = p.lineComment
|
||||||
|
@ -343,9 +343,13 @@ func TestParse_inline(t *testing.T) {
|
|||||||
{"o{{}}", true},
|
{"o{{}}", true},
|
||||||
{"t t e d N{{}}", true},
|
{"t t e d N{{}}", true},
|
||||||
{"t t e d{{}}", true},
|
{"t t e d{{}}", true},
|
||||||
|
{"N{}N{{}}", true},
|
||||||
|
{"v\nN{{}}", true},
|
||||||
|
{"v=/\n[,", true},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
t.Logf("Testing: %q", tc.Value)
|
||||||
ast, err := Parse([]byte(tc.Value))
|
ast, err := Parse([]byte(tc.Value))
|
||||||
if (err != nil) != tc.Err {
|
if (err != nil) != tc.Err {
|
||||||
t.Fatalf("Input: %q\n\nError: %s\n\nAST: %s", tc.Value, err, spew.Sdump(ast))
|
t.Fatalf("Input: %q\n\nError: %s\n\nAST: %s", tc.Value, err, spew.Sdump(ast))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user