mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix fmt error for json decode (#14520)
This commit is contained in:
parent
0eb3f8854d
commit
79a75c5ac0
19
vlib/v/fmt/tests/json_decode_fmt_keep.vv
Normal file
19
vlib/v/fmt/tests/json_decode_fmt_keep.vv
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
struct Request {
|
||||||
|
a int
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse(s string) ?Request {
|
||||||
|
return json.decode(Request, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse2(s string) ?Request {
|
||||||
|
req := json.decode(Request, s)?
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println(parse('{"a": 22} ')?)
|
||||||
|
println(parse2('{"a": 22} ')?)
|
||||||
|
}
|
@ -24,7 +24,6 @@ pub fn (mut p Parser) call_expr(language ast.Language, mod string) ast.CallExpr
|
|||||||
mut or_kind := ast.OrKind.absent
|
mut or_kind := ast.OrKind.absent
|
||||||
if fn_name == 'json.decode' {
|
if fn_name == 'json.decode' {
|
||||||
p.expecting_type = true // Makes name_expr() parse the type `User` in `json.decode(User, txt)`
|
p.expecting_type = true // Makes name_expr() parse the type `User` in `json.decode(User, txt)`
|
||||||
or_kind = .block
|
|
||||||
}
|
}
|
||||||
|
|
||||||
old_expr_mod := p.expr_mod
|
old_expr_mod := p.expr_mod
|
||||||
|
Loading…
Reference in New Issue
Block a user