From 8974aa451371763c131cc735bf55766a20b4b49a Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Wed, 25 Sep 2019 22:10:45 +1000 Subject: [PATCH] compiler/vlib: change `_ :=` to `_ =` and disable `_ :=` --- compiler/fn.v | 2 +- compiler/parser.v | 6 +++--- compiler/table.v | 12 ++++++------ tools/gen_vc.v | 2 +- tools/vget.v | 2 +- vlib/builtin/array.v | 2 +- vlib/crypto/aes/block_generic.v | 4 ++-- vlib/crypto/rc4/rc4.v | 2 +- vlib/encoding/binary/binary.v | 24 ++++++++++++------------ vlib/net/socket_udp_test.v | 2 +- vlib/net/urllib/urllib.v | 6 +++--- vlib/vweb/tmpl/tmpl.v | 2 +- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/compiler/fn.v b/compiler/fn.v index 60a11d43bf..a1d67a75e1 100644 --- a/compiler/fn.v +++ b/compiler/fn.v @@ -90,7 +90,7 @@ fn (p mut Parser) mark_var_changed(v Var) { } fn (p mut Parser) known_var(name string) bool { - _ := p.find_var(name) or { + _ = p.find_var(name) or { return false } return true diff --git a/compiler/parser.v b/compiler/parser.v index 49da5664e8..4d8fdf8d4b 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1378,9 +1378,9 @@ fn (p mut Parser) var_decl() { } for i, name in names { if name == '_' { - // if names.len == 1 { - // p.error('no new variables on left side of :=') - // } + if names.len == 1 { + p.error('no new variables on left side of :=') + } continue } typ := types[i] diff --git a/compiler/table.v b/compiler/table.v index 4fcf8790c1..ee21282584 100644 --- a/compiler/table.v +++ b/compiler/table.v @@ -333,12 +333,12 @@ fn (t &Table) find_fn(name string) ?Fn { } fn (t &Table) known_fn(name string) bool { - _ := t.find_fn(name) or { return false } + _ = t.find_fn(name) or { return false } return true } fn (t &Table) known_const(name string) bool { - _ := t.find_const(name) or { return false } + _ = t.find_const(name) or { return false } return true } @@ -404,7 +404,7 @@ fn (table mut Table) add_field(type_name, field_name, field_type string, is_mut } fn (t &Type) has_field(name string) bool { - _ := t.find_field(name) or { return false } + _ = t.find_field(name) or { return false } return true } @@ -422,7 +422,7 @@ fn (t &Type) find_field(name string) ?Var { } fn (table &Table) type_has_field(typ &Type, name string) bool { - _ := table.find_field(typ, name) or { return false } + _ = table.find_field(typ, name) or { return false } return true } @@ -465,12 +465,12 @@ fn (p mut Parser) add_method(type_name string, f Fn) { } fn (t &Type) has_method(name string) bool { - _ := t.find_method(name) or { return false } + _ = t.find_method(name) or { return false } return true } fn (table &Table) type_has_method(typ &Type, name string) bool { - _ := table.find_method(typ, name) or { return false } + _ = table.find_method(typ, name) or { return false } return true } diff --git a/tools/gen_vc.v b/tools/gen_vc.v index b0a650a129..7ca65bd2d6 100644 --- a/tools/gen_vc.v +++ b/tools/gen_vc.v @@ -117,7 +117,7 @@ fn main() { flag_options := parse_flags(mut fp) - _ := fp.finalize() or { + _ = fp.finalize() or { eprintln(err) println(fp.usage()) return diff --git a/tools/vget.v b/tools/vget.v index 0fa1718d72..c2a4a54a2e 100644 --- a/tools/vget.v +++ b/tools/vget.v @@ -67,7 +67,7 @@ fn main() { final_module_path := '$home_vmodules/' + mod.name.replace('.', '/') println('Installing module "$name" from $mod.url to $final_module_path ...') - _ := os.exec('git clone --depth=1 $mod.url $final_module_path') or { + _ = os.exec('git clone --depth=1 $mod.url $final_module_path') or { errors++ println('Could not install module "$name" to "$final_module_path" .') println('Error details: $err') diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 5a02df49d3..d95af682c8 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -19,7 +19,7 @@ pub: // Private function, used by V (`nums := []int`) fn new_array(mylen, cap, elm_size int) array { a := 3 - _ := a + _ = a //println(a) arr := array { len: mylen diff --git a/vlib/crypto/aes/block_generic.v b/vlib/crypto/aes/block_generic.v index 18f8af2034..0b3d569905 100644 --- a/vlib/crypto/aes/block_generic.v +++ b/vlib/crypto/aes/block_generic.v @@ -43,7 +43,7 @@ import ( // Encrypt one block from src into dst, using the expanded key xk. fn encrypt_block_generic(xk []u32, dst, src []byte) { - mut _ := src[15] // early bounds check + _ = src[15] // early bounds check mut s0 := binary.big_endian_u32(src.left(4)) mut s1 := binary.big_endian_u32(src.slice(4, 8)) mut s2 := binary.big_endian_u32(src.slice(8, 12)) @@ -95,7 +95,7 @@ fn encrypt_block_generic(xk []u32, dst, src []byte) { // Decrypt one block from src into dst, using the expanded key xk. fn decrypt_block_generic(xk []u32, dst, src []byte) { - mut _ := src[15] // early bounds check + _ = src[15] // early bounds check mut s0 := binary.big_endian_u32(src.left(4)) mut s1 := binary.big_endian_u32(src.slice(4, 8)) mut s2 := binary.big_endian_u32(src.slice(8, 12)) diff --git a/vlib/crypto/rc4/rc4.v b/vlib/crypto/rc4/rc4.v index 4694d4b8fe..397eabebab 100644 --- a/vlib/crypto/rc4/rc4.v +++ b/vlib/crypto/rc4/rc4.v @@ -68,7 +68,7 @@ pub fn (c mut Cipher) xor_key_stream(dst mut []byte, src []byte) { } mut i := c.i mut j := c.j - _ := dst[src.len-1] + _ = dst[src.len-1] *dst = dst.left(src.len) // eliminate bounds check from loop for k, v in src { i += byte(1) diff --git a/vlib/encoding/binary/binary.v b/vlib/encoding/binary/binary.v index 05c819e01f..3416b32d8c 100644 --- a/vlib/encoding/binary/binary.v +++ b/vlib/encoding/binary/binary.v @@ -8,26 +8,26 @@ module binary // Little Endian [inline] pub fn little_endian_endian_u16(b []byte) u16 { - _ := b[1] // bounds check + _ = b[1] // bounds check return u16(b[0]) | u16(u16(b[1])<> u16(8)) } [inline] pub fn little_endian_u32(b []byte) u32 { - _ := b[3] // bounds check + _ = b[3] // bounds check return u32(b[0]) | u32(u32(b[1])<> u32(8)) b[2] = byte(v >> u32(16)) @@ -36,14 +36,14 @@ pub fn little_endian_put_u32(b mut []byte, v u32) { [inline] pub fn little_endian_u64(b []byte) u64 { - _ := b[7] // bounds check + _ = b[7] // bounds check return u64(b[0]) | u64(u64(b[1])<> u64(8)) b[2] = byte(v >> u64(16)) @@ -57,26 +57,26 @@ pub fn little_endian_put_u64(b mut []byte, v u64) { // Big Endian [inline] pub fn big_endian_u16(b []byte) u16 { - _ := b[1] // bounds check + _ = b[1] // bounds check return u16(b[1]) | u16(u16(b[0])<> u16(8)) b[1] = byte(v) } [inline] pub fn big_endian_u32(b []byte) u32 { - _ := b[3] // bounds check + _ = b[3] // bounds check return u32(b[3]) | u32(u32(b[2])<> u32(24)) b[1] = byte(v >> u32(16)) b[2] = byte(v >> u32(8)) @@ -85,14 +85,14 @@ pub fn big_endian_put_u32(b mut []byte, v u32) { [inline] pub fn big_endian_u64(b []byte) u64 { - _ := b[7] // bounds check + _ = b[7] // bounds check return u64(b[7]) | u64(u64(b[6])<> u64(56)) b[1] = byte(v >> u64(48)) b[2] = byte(v >> u64(40)) diff --git a/vlib/net/socket_udp_test.v b/vlib/net/socket_udp_test.v index f28c55c1d2..c9fd5bfad4 100644 --- a/vlib/net/socket_udp_test.v +++ b/vlib/net/socket_udp_test.v @@ -4,7 +4,7 @@ fn start_socket_udp_server() { bufsize := 1024 bytes := [1024]byte s := net.socket_udp() or { panic(err) } - _ := s.bind( 9876 ) or { panic(err) } + _ = s.bind( 9876 ) or { panic(err) } println('Waiting for udp packets:') for { res := s.crecv(bytes, bufsize) diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index 127e789103..fae6e21dbf 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -527,7 +527,7 @@ fn _parse(rawurl string, via_request bool) ?URL { // raw_path is a hint of the encoding of path. We don't want to set it if // the default escaping of path is equivalent, to help make sure that people // don't rely on it in general. - _ := url.set_path(rest) or { + _ = url.set_path(rest) or { return error(err) } return url @@ -812,7 +812,7 @@ pub fn (u &URL) str() string { // interpreted as a key set to an empty value. pub fn parse_query(query string) ?Values { mut m := new_values() - _ := _parse_query(mut m, query) or { + _ = _parse_query(mut m, query) or { return error(err) } return m @@ -822,7 +822,7 @@ pub fn parse_query(query string) ?Values { // but any errors will be silent fn parse_query_silent(query string) Values { mut m := new_values() - _ := _parse_query(mut m, query) + _ = _parse_query(mut m, query) return m } diff --git a/vlib/vweb/tmpl/tmpl.v b/vlib/vweb/tmpl/tmpl.v index f229944318..74a6fac93f 100644 --- a/vlib/vweb/tmpl/tmpl.v +++ b/vlib/vweb/tmpl/tmpl.v @@ -31,7 +31,7 @@ pub fn compile_template(path string) string { s.writeln('module main import strings fn ${base}_view() string { // this line will get removed becase only function body is embedded mut sb := strings.new_builder(${lines.len * 30}) header := \'$header\' -_ := header +_ = header //footer := \'footer\' ') s.writeln(STR_START)