diff --git a/zcl/json/parser.go b/zcl/json/parser.go index 1c3924f..1272673 100644 --- a/zcl/json/parser.go +++ b/zcl/json/parser.go @@ -27,10 +27,6 @@ func parseFileContent(buf []byte, filename string) (node, zcl.Diagnostics) { Subject: p.Peek().Range.Ptr(), }) } - if diags.HasErrors() { - // Don't return a node if there were errors during parsing. - return nil, diags - } return node, diags } diff --git a/zcl/json/parser_test.go b/zcl/json/parser_test.go index 8bb7a93..62e5fd0 100644 --- a/zcl/json/parser_test.go +++ b/zcl/json/parser_test.go @@ -190,7 +190,13 @@ func TestParse(t *testing.T) { }, { `1 2`, - nil, + &numberVal{ + Value: mustBigFloat("1"), + SrcRange: zcl.Range{ + Start: zcl.Pos{Line: 1, Column: 1, Byte: 0}, + End: zcl.Pos{Line: 1, Column: 2, Byte: 1}, + }, + }, 1, }, @@ -306,7 +312,32 @@ func TestParse(t *testing.T) { }, { `{"hello": true, "hello": true}`, - nil, + &objectVal{ + Attrs: map[string]*objectAttr{ + "hello": { + Name: "hello", + Value: &booleanVal{ + Value: true, + SrcRange: zcl.Range{ + Start: zcl.Pos{Line: 1, Column: 26, Byte: 25}, + End: zcl.Pos{Line: 1, Column: 30, Byte: 29}, + }, + }, + NameRange: zcl.Range{ + Start: zcl.Pos{Line: 1, Column: 17, Byte: 16}, + End: zcl.Pos{Line: 1, Column: 24, Byte: 23}, + }, + }, + }, + SrcRange: zcl.Range{ + Start: zcl.Pos{Line: 1, Column: 1, Byte: 0}, + End: zcl.Pos{Line: 1, Column: 31, Byte: 30}, + }, + OpenRange: zcl.Range{ + Start: zcl.Pos{Line: 1, Column: 1, Byte: 0}, + End: zcl.Pos{Line: 1, Column: 2, Byte: 1}, + }, + }, 1, }, {