mirror of
https://github.com/vlang/v.git
synced 2025-09-08 06:41:58 -04:00
checker: fix json.encode_pretty
with a struct init expression argument (#22897)
This commit is contained in:
parent
47c785886c
commit
3bf459c0d2
@ -461,6 +461,13 @@ fn test_omit_empty() {
|
||||
// println(json.encode_pretty(foo))
|
||||
}
|
||||
|
||||
fn test_encode_struct_expression() {
|
||||
assert json.encode(Foo2{'Foo'}) == '{"name":"Foo"}'
|
||||
assert json.encode_pretty(Foo2{'Bar'}) == '{
|
||||
"name": "Bar"
|
||||
}'
|
||||
}
|
||||
|
||||
struct Asdasd {
|
||||
data GamePacketData
|
||||
}
|
||||
|
@ -1563,8 +1563,8 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
|
||||
|| final_param_sym.idx == ast.voidptr_type_idx
|
||||
|| param.typ == ast.nil_type || final_param_sym.idx == ast.nil_type_idx)
|
||||
&& !call_arg.typ.is_any_kind_of_pointer() && func.language == .v
|
||||
&& !call_arg.expr.is_lvalue() && func.name != 'json.encode' && !c.pref.translated
|
||||
&& !c.file.is_translated {
|
||||
&& !call_arg.expr.is_lvalue() && !c.pref.translated && !c.file.is_translated
|
||||
&& func.name !in ['json.encode', 'json.encode_pretty'] {
|
||||
c.error('expression cannot be passed as `voidptr`', call_arg.expr.pos())
|
||||
}
|
||||
// Handle expected interface
|
||||
|
Loading…
x
Reference in New Issue
Block a user