vfmt: fix `struct Abc { field fn() ? }`

pull/7398/head
Delyan Angelov 2020-12-18 11:28:05 +02:00
parent 7feb53b605
commit 04757a4853
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,4 @@
struct FieldsWithOptionalVoidReturnType {
f fn () ?
g fn () ?
}

View File

@ -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'
}

View File

@ -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)