fmt: process RangeExpr properly

pull/3822/head^2
Alexey 2020-02-24 18:37:20 +03:00 committed by GitHub
parent 7d2eb4f604
commit 2bbb8526a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -425,9 +425,11 @@ fn (f mut Fmt) index_expr(node ast.IndexExpr) {
ast.RangeExpr {
is_range = true
f.expr(node.left)
f.write('[')
f.expr(it.low)
f.write('..')
f.expr(it.high)
f.write(')')
f.write(']')
}
else {}
}

View File

@ -41,6 +41,10 @@ fn new_user() User {
}
}
fn fn_contains_range_expr() {
a := 1 in arr[0..2]
}
fn voidfn() {
println('this is a function that does not return anything')
}

View File

@ -45,6 +45,10 @@ User
}
}
fn fn_contains_range_expr() {
a:=1 in arr[0..2]
}
fn voidfn(){
println('this is a function that does not return anything')
}
@ -103,4 +107,3 @@ reserved_types = {
'i128': true
}
)