x.json2: fix `direct sum type init` notices

pull/9681/head
Delyan Angelov 2021-04-11 11:28:52 +03:00
parent 954c436d28
commit c939e4df97
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 10 additions and 10 deletions

View File

@ -144,7 +144,7 @@ fn (mut p Parser) decode_value() ?Any {
}) })
} }
} }
return Any{} return Any(null)
} }
fn (mut p Parser) decode_array() ?Any { fn (mut p Parser) decode_array() ?Any {

View File

@ -3,7 +3,7 @@ import x.json2
fn test_raw_decode_string() { fn test_raw_decode_string() {
str := json2.raw_decode('"Hello!"') or { str := json2.raw_decode('"Hello!"') or {
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
assert str.str() == 'Hello!' assert str.str() == 'Hello!'
} }
@ -11,7 +11,7 @@ fn test_raw_decode_string() {
fn test_raw_decode_number() { fn test_raw_decode_number() {
num := json2.raw_decode('123') or { num := json2.raw_decode('123') or {
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
assert num.int() == 123 assert num.int() == 123
} }
@ -19,7 +19,7 @@ fn test_raw_decode_number() {
fn test_raw_decode_array() { fn test_raw_decode_array() {
raw_arr := json2.raw_decode('["Foo", 1]') or { raw_arr := json2.raw_decode('["Foo", 1]') or {
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
arr := raw_arr.arr() arr := raw_arr.arr()
assert arr[0].str() == 'Foo' assert arr[0].str() == 'Foo'
@ -29,7 +29,7 @@ fn test_raw_decode_array() {
fn test_raw_decode_bool() { fn test_raw_decode_bool() {
bol := json2.raw_decode('false') or { bol := json2.raw_decode('false') or {
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
assert bol.bool() == false assert bol.bool() == false
} }
@ -37,7 +37,7 @@ fn test_raw_decode_bool() {
fn test_raw_decode_map() { fn test_raw_decode_map() {
raw_mp := json2.raw_decode('{"name":"Bob","age":20}') or { raw_mp := json2.raw_decode('{"name":"Bob","age":20}') or {
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
mp := raw_mp.as_map() mp := raw_mp.as_map()
assert mp['name'].str() == 'Bob' assert mp['name'].str() == 'Bob'
@ -47,7 +47,7 @@ fn test_raw_decode_map() {
fn test_raw_decode_null() { fn test_raw_decode_null() {
nul := json2.raw_decode('null') or { nul := json2.raw_decode('null') or {
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
assert nul is json2.Null assert nul is json2.Null
} }
@ -63,7 +63,7 @@ fn test_raw_decode_invalid() {
fn test_raw_decode_string_with_dollarsign() { fn test_raw_decode_string_with_dollarsign() {
str := json2.raw_decode(r'"Hello $world"') or { str := json2.raw_decode(r'"Hello $world"') or {
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
assert str.str() == r'Hello $world' assert str.str() == r'Hello $world'
} }
@ -72,7 +72,7 @@ fn test_raw_decode_map_with_whitespaces() {
raw_mp := json2.raw_decode(' \n\t{"name":"Bob","age":20}\n\t') or { raw_mp := json2.raw_decode(' \n\t{"name":"Bob","age":20}\n\t') or {
eprintln(err.msg) eprintln(err.msg)
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
mp := raw_mp.as_map() mp := raw_mp.as_map()
assert mp['name'].str() == 'Bob' assert mp['name'].str() == 'Bob'

View File

@ -63,7 +63,7 @@ fn test_fast_raw_decode() {
s := '{"name":"Peter","age":28,"salary":95000.5,"title":2}' s := '{"name":"Peter","age":28,"salary":95000.5,"title":2}'
o := json2.fast_raw_decode(s) or { o := json2.fast_raw_decode(s) or {
assert false assert false
json2.Any{} json2.Any(json2.null)
} }
str := o.str() str := o.str()
assert str == '{"name":"Peter","age":"28","salary":"95000.5","title":"2"}' assert str == '{"name":"Peter","age":"28","salary":"95000.5","title":"2"}'