mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
39d2aa71df
commit
6bf2ad1ff0
@ -1036,7 +1036,7 @@ fn (g Gen) optional_type_text(styp string, base string) string {
|
|||||||
} else if base.starts_with('anon_fn') {
|
} else if base.starts_with('anon_fn') {
|
||||||
'void*'
|
'void*'
|
||||||
} else {
|
} else {
|
||||||
base
|
if base.starts_with('struct ') && !base.ends_with('*') { '$base*' } else { base }
|
||||||
}
|
}
|
||||||
ret := 'struct $styp {
|
ret := 'struct $styp {
|
||||||
byte state;
|
byte state;
|
||||||
@ -1053,7 +1053,7 @@ fn (g Gen) result_type_text(styp string, base string) string {
|
|||||||
} else if base.starts_with('anon_fn') {
|
} else if base.starts_with('anon_fn') {
|
||||||
'void*'
|
'void*'
|
||||||
} else {
|
} else {
|
||||||
base
|
if base.starts_with('struct ') && !base.ends_with('*') { '$base*' } else { base }
|
||||||
}
|
}
|
||||||
ret := 'struct $styp {
|
ret := 'struct $styp {
|
||||||
bool is_error;
|
bool is_error;
|
||||||
|
@ -390,6 +390,15 @@ fn test_optional_ref_c_struct_gen() {
|
|||||||
_ := get_opt_pointer_to_c_struct() or { &C.stat{} }
|
_ := get_opt_pointer_to_c_struct() or { &C.stat{} }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For issue #16070: cgen error: missing * of optional non-ref structs
|
||||||
|
fn get_opt_to_c_struct() ?C.stat {
|
||||||
|
return none
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_optional_c_struct_gen() {
|
||||||
|
_ := get_opt_to_c_struct() or { C.stat{} }
|
||||||
|
}
|
||||||
|
|
||||||
// For issue #16062: checker disallow the return of voidptr(nil) in or block
|
// For issue #16062: checker disallow the return of voidptr(nil) in or block
|
||||||
struct Bar {}
|
struct Bar {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user