v/fmt: fix formatting of `type Foo = fn (a int)?` (#6047)

pull/6064/head
Swastik Baranwal 2020-08-03 21:58:48 +05:30 committed by GitHub
parent f605022481
commit c547e8b191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -562,7 +562,9 @@ pub fn (mut f Fmt) type_decl(node ast.TypeDecl) {
f.write(')') f.write(')')
if fn_info.return_type.idx() != table.void_type_idx { if fn_info.return_type.idx() != table.void_type_idx {
ret_str := f.no_cur_mod(f.table.type_to_str(fn_info.return_type)) ret_str := f.no_cur_mod(f.table.type_to_str(fn_info.return_type))
f.write(' ' + ret_str) f.write(' $ret_str')
} else if fn_info.return_type.has_flag(.optional) {
f.write(' ?')
} }
} }
ast.SumTypeDecl { ast.SumTypeDecl {

View File

@ -0,0 +1,3 @@
type Foo = fn (a int) ?
type Foo2 = fn (num int) ?int

View File

@ -0,0 +1,3 @@
type Foo = fn (a int)?
type Foo2 = fn (num int)?int