mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix result of typeof function returns result type (#17849)
This commit is contained in:
parent
51ad565ed6
commit
c7237b1c58
@ -479,6 +479,8 @@ fn (mut g Gen) fn_decl_str(info ast.FnType) string {
|
||||
x := util.strip_main_name(g.table.get_type_name(g.unwrap_generic(info.func.return_type)))
|
||||
if info.func.return_type.has_flag(.option) {
|
||||
fn_str += ' ?${x}'
|
||||
} else if info.func.return_type.has_flag(.result) {
|
||||
fn_str += ' !${x}'
|
||||
} else {
|
||||
fn_str += ' ${x}'
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
fn test_typeof_fn() {
|
||||
assert typeof[fn (s string, x u32) (int, f32)]().name == 'fn (string, u32) (int, f32)'
|
||||
assert typeof[fn (s string, x u32) ?(int, f32)]().name == 'fn (string, u32) ?(int, f32)'
|
||||
assert typeof[fn (s string, x u32) !(int, f32)]().name == 'fn (string, u32) !(int, f32)'
|
||||
}
|
||||
|
||||
fn test_typeof_int() {
|
||||
|
Loading…
Reference in New Issue
Block a user