diff --git a/vlib/strings/builder.v b/vlib/strings/builder.v index 1c8bae1ac5..cec4f6cd07 100644 --- a/vlib/strings/builder.v +++ b/vlib/strings/builder.v @@ -98,8 +98,8 @@ pub fn (mut b Builder) writeln(s string) { b << byte(`\n`) } -// buf == 'hello world' // last_n(5) returns 'world' +// buf == 'hello world' pub fn (b &Builder) last_n(n int) string { if n > b.len { return '' @@ -108,8 +108,8 @@ pub fn (b &Builder) last_n(n int) string { return x.bytestr() } -// buf == 'hello world' // after(6) returns 'world' +// buf == 'hello world' pub fn (b &Builder) after(n int) string { if n >= b.len { return '' @@ -133,7 +133,7 @@ pub fn (mut b Builder) str() string { return s } -// free - manually free the contents of the buffer +// free is for manually freeing the contents of the buffer [unsafe] pub fn (mut b Builder) free() { unsafe { free(b.data) } diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 96e1a2e4b0..f60ee8173f 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -688,11 +688,6 @@ fn (mut s Scanner) text_scan() token.Token { s.is_inter_end = true s.is_inter_start = false } - if s.pos == 0 && next_char == ` ` { - // If a single letter name at the start of the file, increment - // Otherwise the scanner would be stuck at s.pos = 0 - s.pos++ - } return s.new_token(.name, name, name.len) } else if c.is_digit() || (c == `.` && nextc.is_digit()) { // `123`, `.123` diff --git a/vlib/v/scanner/tests/position_0_err.out b/vlib/v/scanner/tests/position_0_err.out new file mode 100644 index 0000000000..c332f4bdf4 --- /dev/null +++ b/vlib/v/scanner/tests/position_0_err.out @@ -0,0 +1,5 @@ +vlib/v/scanner/tests/position_0_err.vv:1:1: error: unused variable: `i` + 1 | i := 'hello' + | ^ + 2 | x := 3 + 3 | y := 2 diff --git a/vlib/v/scanner/tests/position_0_err.vv b/vlib/v/scanner/tests/position_0_err.vv new file mode 100644 index 0000000000..957775b027 --- /dev/null +++ b/vlib/v/scanner/tests/position_0_err.vv @@ -0,0 +1,4 @@ +i := 'hello' +x := 3 +y := 2 +println(x + y) diff --git a/vlib/v/tests/valgrind/simple_interpolation_script_mode.v b/vlib/v/tests/valgrind/simple_interpolation_script_mode.v index 9090ae79cb..54ea943f96 100644 --- a/vlib/v/tests/valgrind/simple_interpolation_script_mode.v +++ b/vlib/v/tests/valgrind/simple_interpolation_script_mode.v @@ -1,5 +1,4 @@ +// TODO: @medvednikov: autofree on script mode does not work when first variable is on position 0 due to the code in `cgen.v:1115` v := 't' - s := '${v}.tmp' - println(s)