diff --git a/compiler/parser.v b/compiler/parser.v index a3d5384843..d2494964d1 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1022,12 +1022,9 @@ fn (p mut Parser) get_type() string { p.register_array(typ) } p.next() - if p.tok == .question || is_question { + if is_question { typ = 'Option_$typ' p.table.register_type_with_parent(typ, 'Option') - if p.tok == .question { - p.next() - } } // Because the code uses * to see if it's a pointer if typ == 'byteptr' { diff --git a/compiler/parser2.v b/compiler/parser2.v index daafe20b8f..286f4e1487 100644 --- a/compiler/parser2.v +++ b/compiler/parser2.v @@ -154,17 +154,13 @@ fn (p mut Parser) get_type2() Type { } else if is_arr { typ = 'array_$typ' - // p.log('ARR TYPE="$typ" run=$p.pass') // We come across "[]User" etc ? p.register_array(typ) } p.next() - if p.tok == .question || is_question { + if is_question { typ = 'Option_$typ' p.table.register_type_with_parent(typ, 'Option') - if p.tok == .question { - p.next() - } } if typ.last_index('__') > typ.index('__') { p.error('2 __ in gettype(): typ="$typ"') diff --git a/compiler/tests/repl/runner/runner.v b/compiler/tests/repl/runner/runner.v index 1c325fe121..c310cc3327 100644 --- a/compiler/tests/repl/runner/runner.v +++ b/compiler/tests/repl/runner/runner.v @@ -25,7 +25,7 @@ pub fn full_path_to_v() string { return vexec } -pub fn run_repl_file(wd string, vexec string, file string) string? { +pub fn run_repl_file(wd string, vexec string, file string) ?string { fcontent := os.read_file(file) or { return error('Could not read file $file') } content := fcontent.replace('\r', '') input := content.all_before('===output===\n') diff --git a/vlib/crypto/rand/utils.v b/vlib/crypto/rand/utils.v index fba5ee0e57..fff9012d25 100644 --- a/vlib/crypto/rand/utils.v +++ b/vlib/crypto/rand/utils.v @@ -9,7 +9,7 @@ import( encoding.binary ) -pub fn int_u64(max u64) u64? { +pub fn int_u64(max u64) ?u64 { bitlen := bits.len64(max) if bitlen == 0 { return u64(0) @@ -38,7 +38,7 @@ pub fn int_u64(max u64) u64? { return n } -fn bytes_to_u64(b []byte) []u64 { +fn bytes_to_u64(b []byte) []u64 { ws := 64/8 mut z := [u64(0)].repeat((b.len + ws - 1) / ws) mut i := b.len diff --git a/vlib/net/socket.v b/vlib/net/socket.v index 02c81693a0..2db6c35899 100644 --- a/vlib/net/socket.v +++ b/vlib/net/socket.v @@ -206,7 +206,7 @@ pub fn dial(address string, port int) ?Socket { } // send string data to socket -pub fn (s Socket) send(buf byteptr, len int) int? { +pub fn (s Socket) send(buf byteptr, len int) ?int { res := int( C.send(s.sockfd, buf, len, 0) ) if res < 0 { return error('socket: send failed') diff --git a/vlib/net/socket_test.v b/vlib/net/socket_test.v index f968054944..d5d1933020 100644 --- a/vlib/net/socket_test.v +++ b/vlib/net/socket_test.v @@ -1,10 +1,10 @@ -import net +import net fn test_socket() { mut server := net.listen(0) or { println(err) return - } + } server_port := server.get_port() mut client := net.dial('127.0.0.1', server_port) or { println(err) @@ -20,7 +20,7 @@ fn test_socket() { $if debug { println('message send: $message') } $if debug { println('send socket: $socket.sockfd') } - bytes, blen := client.recv(1024) + bytes, blen := client.recv(1024) received := tos(bytes, blen) $if debug { println('message received: $received') } $if debug { println('client: $client.sockfd') } @@ -30,4 +30,4 @@ fn test_socket() { server.close() client.close() socket.close() -} +}