From 62ee4369442251e0e0b87755df776e5b60f8f9b9 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 27 Nov 2020 03:07:37 +0100 Subject: [PATCH] all: remove broken escape sequences after $ in strings --- vlib/v/builder/c.v | 4 ++-- vlib/v/builder/cc.v | 2 +- vlib/v/builder/compile.v | 2 +- vlib/v/checker/checker.v | 8 ++++---- vlib/v/gen/auto_str_methods.v | 4 ++-- vlib/v/parser/parser.v | 2 +- vlib/v/scanner/scanner.v | 7 +++++-- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/vlib/v/builder/c.v b/vlib/v/builder/c.v index 2690e31b0c..93cafd3fb3 100644 --- a/vlib/v/builder/c.v +++ b/vlib/v/builder/c.v @@ -84,8 +84,8 @@ pub fn (mut b Builder) compile_c() { bundle_name := b.pref.out_name.split('/').last() bundle_id := if b.pref.bundle_id != '' { b.pref.bundle_id } else { 'app.vlang.$bundle_name' } display_name := if b.pref.display_name != '' { b.pref.display_name } else { bundle_name } - os.mkdir('$display_name\.app') - os.write_file('$display_name\.app/Info.plist', make_ios_plist(display_name, bundle_id, + os.mkdir('${display_name}.app') + os.write_file('${display_name}.app/Info.plist', make_ios_plist(display_name, bundle_id, bundle_name, 1)) } b.cc() diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index da2af815d9..11d51e3bff 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -439,7 +439,7 @@ fn (mut v Builder) cc() { // Output executable name if v.pref.os == .ios { bundle_name := v.pref.out_name.split('/').last() - args << '-o "$v.pref.out_name\.app/$bundle_name"' + args << '-o "${v.pref.out_name}.app/$bundle_name"' } else { args << '-o "$v.pref.out_name"' } diff --git a/vlib/v/builder/compile.v b/vlib/v/builder/compile.v index 9ab79b7c66..6373e764ef 100644 --- a/vlib/v/builder/compile.v +++ b/vlib/v/builder/compile.v @@ -92,7 +92,7 @@ fn (mut b Builder) run_compiled_executable_and_exit() { os.exec('xcrun simctl boot $device') bundle_name := b.pref.out_name.split('/').last() display_name := if b.pref.display_name != '' { b.pref.display_name } else { bundle_name } - os.exec('xcrun simctl install $device $display_name\.app') + os.exec('xcrun simctl install $device ${display_name}.app') bundle_id := if b.pref.bundle_id != '' { b.pref.bundle_id } else { 'app.vlang.$bundle_name' } os.exec('xcrun simctl launch $device $bundle_id') } else { diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 531bf61014..9637e0970b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2731,19 +2731,19 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) { fn (mut c Checker) import_stmt(imp ast.Import) { for sym in imp.syms { - name := '$imp.mod\.$sym.name' + name := '${imp.mod}.$sym.name' if sym.kind == .fn_ { c.table.find_fn(name) or { - c.error('module `$imp.mod` has no public fn named `$sym.name\()`', sym.pos) + c.error('module `$imp.mod` has no public fn named `${sym.name}()`', sym.pos) } } if sym.kind == .type_ { if type_sym := c.table.find_type(name) { if type_sym.kind == .placeholder || !type_sym.is_public { - c.error('module `$imp.mod` has no public type `$sym.name\{}`', sym.pos) + c.error('module `$imp.mod` has no public type `$sym.name{}`', sym.pos) } } else { - c.error('module `$imp.mod` has no public type `$sym.name\{}`', sym.pos) + c.error('module `$imp.mod` has no public type `$sym.name{}`', sym.pos) } } } diff --git a/vlib/v/gen/auto_str_methods.v b/vlib/v/gen/auto_str_methods.v index 0bbe8aae1f..062b6eae5a 100644 --- a/vlib/v/gen/auto_str_methods.v +++ b/vlib/v/gen/auto_str_methods.v @@ -77,7 +77,7 @@ fn (mut g Gen) gen_str_for_type_with_styp(typ table.Type, styp string) string { g.gen_str_for_union_sum_type(sym.info, styp, str_fn_name) } else { - verror("could not generate string method $str_fn_name for type \'$styp\'") + verror("could not generate string method $str_fn_name for type '$styp'") } } } @@ -512,7 +512,7 @@ fn (mut g Gen) gen_str_for_union_sum_type(info table.SumType, styp string, str_f for typ in info.variants { mut value_fmt := '%.*s\\000' if typ == table.string_type { - value_fmt = "\'$value_fmt\'" + value_fmt = "'$value_fmt'" } typ_str := g.typ(typ) mut func_name := if typ_str in gen_fn_names { gen_fn_names[typ_str] } else { g.gen_str_for_type_with_styp(typ, diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 522c1e3b71..bab28b38f1 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1612,7 +1612,7 @@ fn (mut p Parser) import_syms(mut parent ast.Import) { for p.tok.kind == .name { pos := p.tok.position() alias := p.check_name() - name := '$parent.mod\.$alias' + name := '${parent.mod}.$alias' if alias[0].is_capital() { idx := p.table.add_placeholder_type(name, .v) typ := table.new_type(idx) diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 9c2fb59067..ebea4a94aa 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -579,9 +579,12 @@ fn (mut s Scanner) text_scan() token.Token { } // end of `$expr` // allow `'$a.b'` and `'$a.c()'` + if s.is_inter_start && next_char == `\\` && s.look_ahead(2) !in [`n`, `\\`, `t`] { + // s.warn('unknown escape sequence \\${s.look_ahead(2)}') + } if s.is_inter_start && next_char == `(` { if s.look_ahead(2) != `)` { - s.warn('use e.g. `\${f(expr)}` or `\$name\\(` instead of `\$f(expr)`') + s.warn('use `\${f(expr)}` instead of `\$f(expr)`') } } else if s.is_inter_start && next_char != `.` { s.is_inter_end = true @@ -1036,7 +1039,7 @@ fn (mut s Scanner) ident_string() string { s.error(r'cannot use `\x00` (NULL character) in the string literal') } } - // ${var} (ignore in vfmt mode) + // ${var} (ignore in vfmt mode) (skip \$) if prevc == `$` && c == `{` && !is_raw && s.count_symbol_before(s.pos - 2, slash) % 2 == 0 { s.is_inside_string = true // so that s.pos points to $ at the next step