fmt: add a space after + operator/method overload (#7453)

pull/7460/head
Lukas Neubert 2020-12-21 20:20:00 +01:00 committed by GitHub
parent 74f7a1a549
commit 304aafdc50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 4 deletions

View File

@ -50,6 +50,9 @@ pub fn (node &FnDecl) stringify(t &table.Table, cur_mod string) string {
name = 'JS.$name'
}
f.write('fn $receiver$name')
if name in ['+', '-', '*', '/', '%'] {
f.write(' ')
}
if node.is_generic {
f.write('<T>')
}

View File

@ -0,0 +1,11 @@
struct Foo {
x int
}
fn (a Foo) + (b Foo) Foo {
return Foo{a.x + b.x}
}
fn (a Foo) % (b Foo) Foo {
return Foo{a.x % b.x}
}