mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
fix type_default for empty structs
This commit is contained in:
parent
56f20d1ff8
commit
b1914fc217
2 changed files with 3 additions and 4 deletions
|
@ -7574,8 +7574,9 @@ fn (mut g Gen) type_default_impl(typ_ ast.Type, decode_sumtype bool) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.struct {
|
.struct {
|
||||||
mut has_none_zero := false
|
|
||||||
info := sym.info as ast.Struct
|
info := sym.info as ast.Struct
|
||||||
|
mut has_none_zero := info.fields.len == 0
|
||||||
|
|
||||||
mut init_str := if info.is_anon && !g.inside_global_decl {
|
mut init_str := if info.is_anon && !g.inside_global_decl {
|
||||||
'(${g.styp(typ)}){'
|
'(${g.styp(typ)}){'
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,9 +24,7 @@ pub type Any = []Any
|
||||||
| Null
|
| Null
|
||||||
|
|
||||||
// Null is a simple representation of the `null` value in JSON.
|
// Null is a simple representation of the `null` value in JSON.
|
||||||
pub struct Null {
|
pub struct Null {}
|
||||||
is_null bool = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// null is an instance of the Null type, to ease comparisons with it.
|
// null is an instance of the Null type, to ease comparisons with it.
|
||||||
pub const null = Null{}
|
pub const null = Null{}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue