mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: fix struct Abc { field fn() ? }
This commit is contained in:
parent
7feb53b605
commit
04757a4853
4
vlib/v/fmt/tests/struct_with_fn_fields_keep.vv
Normal file
4
vlib/v/fmt/tests/struct_with_fn_fields_keep.vv
Normal file
@ -0,0 +1,4 @@
|
||||
struct FieldsWithOptionalVoidReturnType {
|
||||
f fn () ?
|
||||
g fn () ?
|
||||
}
|
@ -120,7 +120,9 @@ pub fn (t &Table) fn_type_source_signature(f &Fn) string {
|
||||
}
|
||||
}
|
||||
sig += ')'
|
||||
if f.return_type != void_type {
|
||||
if f.return_type == ovoid_type {
|
||||
sig += ' ?'
|
||||
} else if f.return_type != void_type {
|
||||
return_type_sym := t.get_type_symbol(f.return_type)
|
||||
sig += ' $return_type_sym.name'
|
||||
}
|
||||
|
@ -335,6 +335,7 @@ pub const (
|
||||
|
||||
pub const (
|
||||
void_type = new_type(void_type_idx)
|
||||
ovoid_type = new_type(void_type_idx).set_flag(.optional) // the return type of `fn () ?`
|
||||
voidptr_type = new_type(voidptr_type_idx)
|
||||
byteptr_type = new_type(byteptr_type_idx)
|
||||
charptr_type = new_type(charptr_type_idx)
|
||||
|
Loading…
Reference in New Issue
Block a user