mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler/vlib: change _ :=
to _ =
and disable _ :=
This commit is contained in:
parent
746655c1d5
commit
8974aa4513
@ -90,7 +90,7 @@ fn (p mut Parser) mark_var_changed(v Var) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn (p mut Parser) known_var(name string) bool {
|
fn (p mut Parser) known_var(name string) bool {
|
||||||
_ := p.find_var(name) or {
|
_ = p.find_var(name) or {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -1378,9 +1378,9 @@ fn (p mut Parser) var_decl() {
|
|||||||
}
|
}
|
||||||
for i, name in names {
|
for i, name in names {
|
||||||
if name == '_' {
|
if name == '_' {
|
||||||
// if names.len == 1 {
|
if names.len == 1 {
|
||||||
// p.error('no new variables on left side of :=')
|
p.error('no new variables on left side of :=')
|
||||||
// }
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
typ := types[i]
|
typ := types[i]
|
||||||
|
@ -333,12 +333,12 @@ fn (t &Table) find_fn(name string) ?Fn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn (t &Table) known_fn(name string) bool {
|
fn (t &Table) known_fn(name string) bool {
|
||||||
_ := t.find_fn(name) or { return false }
|
_ = t.find_fn(name) or { return false }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (t &Table) known_const(name string) bool {
|
fn (t &Table) known_const(name string) bool {
|
||||||
_ := t.find_const(name) or { return false }
|
_ = t.find_const(name) or { return false }
|
||||||
return true
|
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 {
|
fn (t &Type) has_field(name string) bool {
|
||||||
_ := t.find_field(name) or { return false }
|
_ = t.find_field(name) or { return false }
|
||||||
return true
|
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 {
|
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
|
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 {
|
fn (t &Type) has_method(name string) bool {
|
||||||
_ := t.find_method(name) or { return false }
|
_ = t.find_method(name) or { return false }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (table &Table) type_has_method(typ &Type, name string) bool {
|
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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ fn main() {
|
|||||||
|
|
||||||
flag_options := parse_flags(mut fp)
|
flag_options := parse_flags(mut fp)
|
||||||
|
|
||||||
_ := fp.finalize() or {
|
_ = fp.finalize() or {
|
||||||
eprintln(err)
|
eprintln(err)
|
||||||
println(fp.usage())
|
println(fp.usage())
|
||||||
return
|
return
|
||||||
|
@ -67,7 +67,7 @@ fn main() {
|
|||||||
final_module_path := '$home_vmodules/' + mod.name.replace('.', '/')
|
final_module_path := '$home_vmodules/' + mod.name.replace('.', '/')
|
||||||
|
|
||||||
println('Installing module "$name" from $mod.url to $final_module_path ...')
|
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++
|
errors++
|
||||||
println('Could not install module "$name" to "$final_module_path" .')
|
println('Could not install module "$name" to "$final_module_path" .')
|
||||||
println('Error details: $err')
|
println('Error details: $err')
|
||||||
|
@ -19,7 +19,7 @@ pub:
|
|||||||
// Private function, used by V (`nums := []int`)
|
// Private function, used by V (`nums := []int`)
|
||||||
fn new_array(mylen, cap, elm_size int) array {
|
fn new_array(mylen, cap, elm_size int) array {
|
||||||
a := 3
|
a := 3
|
||||||
_ := a
|
_ = a
|
||||||
//println(a)
|
//println(a)
|
||||||
arr := array {
|
arr := array {
|
||||||
len: mylen
|
len: mylen
|
||||||
|
@ -43,7 +43,7 @@ import (
|
|||||||
|
|
||||||
// Encrypt one block from src into dst, using the expanded key xk.
|
// Encrypt one block from src into dst, using the expanded key xk.
|
||||||
fn encrypt_block_generic(xk []u32, dst, src []byte) {
|
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 s0 := binary.big_endian_u32(src.left(4))
|
||||||
mut s1 := binary.big_endian_u32(src.slice(4, 8))
|
mut s1 := binary.big_endian_u32(src.slice(4, 8))
|
||||||
mut s2 := binary.big_endian_u32(src.slice(8, 12))
|
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.
|
// Decrypt one block from src into dst, using the expanded key xk.
|
||||||
fn decrypt_block_generic(xk []u32, dst, src []byte) {
|
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 s0 := binary.big_endian_u32(src.left(4))
|
||||||
mut s1 := binary.big_endian_u32(src.slice(4, 8))
|
mut s1 := binary.big_endian_u32(src.slice(4, 8))
|
||||||
mut s2 := binary.big_endian_u32(src.slice(8, 12))
|
mut s2 := binary.big_endian_u32(src.slice(8, 12))
|
||||||
|
@ -68,7 +68,7 @@ pub fn (c mut Cipher) xor_key_stream(dst mut []byte, src []byte) {
|
|||||||
}
|
}
|
||||||
mut i := c.i
|
mut i := c.i
|
||||||
mut j := c.j
|
mut j := c.j
|
||||||
_ := dst[src.len-1]
|
_ = dst[src.len-1]
|
||||||
*dst = dst.left(src.len) // eliminate bounds check from loop
|
*dst = dst.left(src.len) // eliminate bounds check from loop
|
||||||
for k, v in src {
|
for k, v in src {
|
||||||
i += byte(1)
|
i += byte(1)
|
||||||
|
@ -8,26 +8,26 @@ module binary
|
|||||||
// Little Endian
|
// Little Endian
|
||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_endian_u16(b []byte) u16 {
|
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))
|
return u16(b[0]) | u16(u16(b[1])<<u16(8))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_put_u16(b mut []byte, v u16) {
|
pub fn little_endian_put_u16(b mut []byte, v u16) {
|
||||||
_ := b[1] // bounds check
|
_ = b[1] // bounds check
|
||||||
b[0] = byte(v)
|
b[0] = byte(v)
|
||||||
b[1] = byte(v >> u16(8))
|
b[1] = byte(v >> u16(8))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_u32(b []byte) u32 {
|
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)) | u32(u32(b[2])<<u32(16)) | u32(u32(b[3])<<u32(24))
|
return u32(b[0]) | u32(u32(b[1])<<u32(8)) | u32(u32(b[2])<<u32(16)) | u32(u32(b[3])<<u32(24))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_put_u32(b mut []byte, v u32) {
|
pub fn little_endian_put_u32(b mut []byte, v u32) {
|
||||||
_ := b[3] // bounds check
|
_ = b[3] // bounds check
|
||||||
b[0] = byte(v)
|
b[0] = byte(v)
|
||||||
b[1] = byte(v >> u32(8))
|
b[1] = byte(v >> u32(8))
|
||||||
b[2] = byte(v >> u32(16))
|
b[2] = byte(v >> u32(16))
|
||||||
@ -36,14 +36,14 @@ pub fn little_endian_put_u32(b mut []byte, v u32) {
|
|||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_u64(b []byte) u64 {
|
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)) | u64(u64(b[2])<<u64(16)) | u64(u64(b[3])<<u64(24)) |
|
return u64(b[0]) | u64(u64(b[1])<<u64(8)) | u64(u64(b[2])<<u64(16)) | u64(u64(b[3])<<u64(24)) |
|
||||||
u64(u64(b[4])<<u64(32)) | u64(u64(b[5])<<u64(40)) | u64(u64(b[6])<<u64(48)) | u64(u64(b[7])<<u64(56))
|
u64(u64(b[4])<<u64(32)) | u64(u64(b[5])<<u64(40)) | u64(u64(b[6])<<u64(48)) | u64(u64(b[7])<<u64(56))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_put_u64(b mut []byte, v u64) {
|
pub fn little_endian_put_u64(b mut []byte, v u64) {
|
||||||
_ := b[7] // bounds check
|
_ = b[7] // bounds check
|
||||||
b[0] = byte(v)
|
b[0] = byte(v)
|
||||||
b[1] = byte(v >> u64(8))
|
b[1] = byte(v >> u64(8))
|
||||||
b[2] = byte(v >> u64(16))
|
b[2] = byte(v >> u64(16))
|
||||||
@ -57,26 +57,26 @@ pub fn little_endian_put_u64(b mut []byte, v u64) {
|
|||||||
// Big Endian
|
// Big Endian
|
||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_u16(b []byte) u16 {
|
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))
|
return u16(b[1]) | u16(u16(b[0])<<u16(8))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_put_u16(b mut []byte, v u16) {
|
pub fn big_endian_put_u16(b mut []byte, v u16) {
|
||||||
_ := b[1] // bounds check
|
_ = b[1] // bounds check
|
||||||
b[0] = byte(v >> u16(8))
|
b[0] = byte(v >> u16(8))
|
||||||
b[1] = byte(v)
|
b[1] = byte(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_u32(b []byte) u32 {
|
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(8)) | u32(u32(b[1])<<u32(16)) | u32(u32(b[0])<<u32(24))
|
return u32(b[3]) | u32(u32(b[2])<<u32(8)) | u32(u32(b[1])<<u32(16)) | u32(u32(b[0])<<u32(24))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_put_u32(b mut []byte, v u32) {
|
pub fn big_endian_put_u32(b mut []byte, v u32) {
|
||||||
_ := b[3] // bounds check
|
_ = b[3] // bounds check
|
||||||
b[0] = byte(v >> u32(24))
|
b[0] = byte(v >> u32(24))
|
||||||
b[1] = byte(v >> u32(16))
|
b[1] = byte(v >> u32(16))
|
||||||
b[2] = byte(v >> u32(8))
|
b[2] = byte(v >> u32(8))
|
||||||
@ -85,14 +85,14 @@ pub fn big_endian_put_u32(b mut []byte, v u32) {
|
|||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_u64(b []byte) u64 {
|
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(8)) | u64(u64(b[5])<<u64(16)) | u64(u64(b[4])<<u64(24)) |
|
return u64(b[7]) | u64(u64(b[6])<<u64(8)) | u64(u64(b[5])<<u64(16)) | u64(u64(b[4])<<u64(24)) |
|
||||||
u64(u64(b[3])<<u64(32)) | u64(u64(b[2])<<u64(40)) | u64(u64(b[1])<<u64(48)) | u64(u64(b[0])<<u64(56))
|
u64(u64(b[3])<<u64(32)) | u64(u64(b[2])<<u64(40)) | u64(u64(b[1])<<u64(48)) | u64(u64(b[0])<<u64(56))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_put_u64(b mut []byte, v u64) {
|
pub fn big_endian_put_u64(b mut []byte, v u64) {
|
||||||
_ := b[7] // bounds check
|
_ = b[7] // bounds check
|
||||||
b[0] = byte(v >> u64(56))
|
b[0] = byte(v >> u64(56))
|
||||||
b[1] = byte(v >> u64(48))
|
b[1] = byte(v >> u64(48))
|
||||||
b[2] = byte(v >> u64(40))
|
b[2] = byte(v >> u64(40))
|
||||||
|
@ -4,7 +4,7 @@ fn start_socket_udp_server() {
|
|||||||
bufsize := 1024
|
bufsize := 1024
|
||||||
bytes := [1024]byte
|
bytes := [1024]byte
|
||||||
s := net.socket_udp() or { panic(err) }
|
s := net.socket_udp() or { panic(err) }
|
||||||
_ := s.bind( 9876 ) or { panic(err) }
|
_ = s.bind( 9876 ) or { panic(err) }
|
||||||
println('Waiting for udp packets:')
|
println('Waiting for udp packets:')
|
||||||
for {
|
for {
|
||||||
res := s.crecv(bytes, bufsize)
|
res := s.crecv(bytes, bufsize)
|
||||||
|
@ -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
|
// 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
|
// the default escaping of path is equivalent, to help make sure that people
|
||||||
// don't rely on it in general.
|
// don't rely on it in general.
|
||||||
_ := url.set_path(rest) or {
|
_ = url.set_path(rest) or {
|
||||||
return error(err)
|
return error(err)
|
||||||
}
|
}
|
||||||
return url
|
return url
|
||||||
@ -812,7 +812,7 @@ pub fn (u &URL) str() string {
|
|||||||
// interpreted as a key set to an empty value.
|
// interpreted as a key set to an empty value.
|
||||||
pub fn parse_query(query string) ?Values {
|
pub fn parse_query(query string) ?Values {
|
||||||
mut m := new_values()
|
mut m := new_values()
|
||||||
_ := _parse_query(mut m, query) or {
|
_ = _parse_query(mut m, query) or {
|
||||||
return error(err)
|
return error(err)
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
@ -822,7 +822,7 @@ pub fn parse_query(query string) ?Values {
|
|||||||
// but any errors will be silent
|
// but any errors will be silent
|
||||||
fn parse_query_silent(query string) Values {
|
fn parse_query_silent(query string) Values {
|
||||||
mut m := new_values()
|
mut m := new_values()
|
||||||
_ := _parse_query(mut m, query)
|
_ = _parse_query(mut m, query)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
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})
|
mut sb := strings.new_builder(${lines.len * 30})
|
||||||
header := \'$header\'
|
header := \'$header\'
|
||||||
_ := header
|
_ = header
|
||||||
//footer := \'footer\'
|
//footer := \'footer\'
|
||||||
')
|
')
|
||||||
s.writeln(STR_START)
|
s.writeln(STR_START)
|
||||||
|
Loading…
Reference in New Issue
Block a user