fmt: format '1.' to '1.0' (#11312)

pull/11319/head
yuyi 2021-08-26 12:18:27 +08:00 committed by GitHub
parent 714fa3215c
commit b635ff80de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -549,6 +549,9 @@ pub fn (mut f Fmt) expr(node ast.Expr) {
}
ast.FloatLiteral {
f.write(node.val)
if node.val.ends_with('.') {
f.write('0')
}
}
ast.GoExpr {
f.go_expr(node)

View File

@ -0,0 +1,4 @@
fn main() {
a := 1.0
println(a)
}

View File

@ -0,0 +1,4 @@
fn main() {
a := 1.
println(a)
}