diff --git a/compiler/parser.v b/compiler/parser.v index 2193733404..a6101d24e5 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -2109,16 +2109,6 @@ fn (p mut Parser) char_expr() { p.next() } -fn format_str(str string) string { - str = str.replace('"', '\\"') - $if windows { - str = str.replace('\r\n', '\\n') - } - $else { - str = str.replace('\n', '\\n') - } - return str -} fn (p mut Parser) typ_to_fmt(typ string) string { t := p.table.find_type(typ) @@ -2143,6 +2133,15 @@ fn (p mut Parser) typ_to_fmt(typ string) string { return '' } +fn format_str(str string) string { + str = str.replace('"', '\\"') + $if windows { + str = str.replace('\r\n', '\\n') + } + str = str.replace('\n', '\\n') + return str +} + fn (p mut Parser) string_expr() { // println('STRING EXPR') str := p.lit @@ -2156,7 +2155,7 @@ fn (p mut Parser) string_expr() { p.gen('"$f"') } else { - p.gen('tos2("$f")')// TODO dont call strlen here + p.gen('tos2("$f")') } p.next() return