diff --git a/vlib/compiler/fn.v b/vlib/compiler/fn.v index 835e5b67d5..a8c9319b25 100644 --- a/vlib/compiler/fn.v +++ b/vlib/compiler/fn.v @@ -756,7 +756,7 @@ fn (p mut Parser) fn_call(f mut Fn, method_ph int, receiver_var, receiver_type s // probably a typo, do not concern the user with the above error message break } - i += 1 + i++ } } // if p.pref.is_prof { @@ -1271,7 +1271,7 @@ fn (p mut Parser) extract_type_inst(f &Fn, args_ []string) TypeInst { if fa == tp { r.inst[tp] = fa found = true - i += 1 + i++ break } } @@ -1287,7 +1287,7 @@ fn (p mut Parser) extract_type_inst(f &Fn, args_ []string) TypeInst { } // println("extracted $tp => $ti") r.inst[tp] = ti - i += 1 + i++ if i >= f.type_pars.len { break } } if r.inst[f.typ] == '' && f.typ in f.type_pars { diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index bd8b9f867c..3b970c511f 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -1385,6 +1385,10 @@ fn ($v.name mut $v.typ) $p.cur_fn.name (...) { p.gen('= ustring_add($v.name, ') } else { + next := p.peek_token() + if next.tok == .number && next.lit== '1' { + p.warn('use ++ instead of += 1') + } p.gen(' += ') } } diff --git a/vlib/compiler/scanner.v b/vlib/compiler/scanner.v index b3eaa356fe..a28e27fc58 100644 --- a/vlib/compiler/scanner.v +++ b/vlib/compiler/scanner.v @@ -644,8 +644,7 @@ fn (s mut Scanner) scan() ScanRes { return s.end_of_file() } } - mut msg := 'invalid character `${c.str()}`' - s.error(msg) + s.error('invalid character `${c.str()}`') return s.end_of_file() } diff --git a/vlib/strings/builder_c.v b/vlib/strings/builder_c.v index 82656be7b9..2b8298d6c7 100644 --- a/vlib/strings/builder_c.v +++ b/vlib/strings/builder_c.v @@ -19,14 +19,14 @@ pub fn new_builder(initial_size int) Builder { pub fn (b mut Builder) write_b(data byte) { b.buf << data - b.len += 1 + b.len++ } pub fn (b mut Builder) write(s string) { b.buf.push_many(s.str, s.len) //for c in s { //b.buf << c - //} + //} //b.buf << []byte(s) // TODO b.len += s.len } @@ -34,7 +34,7 @@ pub fn (b mut Builder) write(s string) { pub fn (b mut Builder) writeln(s string) { //for c in s { //b.buf << c - //} + //} b.buf.push_many(s.str, s.len) //b.buf << []byte(s) // TODO b.buf << `\n`