fmt: fix formatting backtick char literal

pull/4659/head
Enzo Baldisserri 2020-04-30 09:33:43 +02:00 committed by GitHub
parent c4f672454f
commit 50491670af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 13 deletions

View File

@ -40,14 +40,10 @@ pub fn fmt(file ast.File, table &table.Table) string {
}
f.cur_mod = 'main'
for stmt in file.stmts {
// TODO `if stmt is ast.Import`
match stmt {
ast.Import {
// Just remember the position of the imports for now
f.import_pos = f.out.len
// f.imports(f.file.imports)
}
else {}
if stmt is ast.Import {
// Just remember the position of the imports for now
f.import_pos = f.out.len
// f.imports(f.file.imports)
}
f.stmt(stmt)
}

View File

@ -0,0 +1,3 @@
fn char_backtick() {
`\``
}

View File

@ -5,7 +5,7 @@ fn fn_variadic(arg int, args ...string) {
}
fn fn_with_assign_stmts() {
a, b := fn_with_multi_return()
_, _ := fn_with_multi_return()
}
fn fn_with_multi_return() (int, string) {

View File

@ -5,7 +5,7 @@ fn fn_variadic(arg int, args... string) {
}
fn fn_with_assign_stmts() {
a,b := fn_with_multi_return()
_,_ := fn_with_multi_return()
}
fn fn_with_multi_return() (int,string) {

View File

@ -6,6 +6,7 @@ fn for_in_loop() {
fn for_in_loop_with_counter() {
for i, item in arr {
println(i)
println(item)
}
}

View File

@ -6,6 +6,7 @@ fn for_in_loop() {
fn for_in_loop_with_counter() {
for i, item in arr {
println(i)
println(item)
}
}

View File

@ -929,9 +929,6 @@ fn (s mut Scanner) ident_char() string {
s.error('invalid character literal (more than one character)\n' + 'use quotes for strings, backticks for characters')
}
}
if c == '\\`' {
return '`'
}
// Escapes a `'` character
return if c == "\'" { '\\' + c } else { c }
}