mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: do not allow "int?", only "?int"
This commit is contained in:
@@ -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
|
||||
|
@@ -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')
|
||||
|
@@ -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()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user