checker: require explicit return none (#8060)

pull/8068/head
Daniel Däschle 2021-01-12 11:43:55 +01:00 committed by GitHub
parent 33976246c8
commit 3289dff7ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 16 additions and 13 deletions

View File

@ -113,4 +113,5 @@ pub fn (mut r BufferedReader) read_line() ?string {
line << r.buf[r.offset..i]
r.offset = i
}
return none
}

View File

@ -36,9 +36,11 @@ struct Zzz_CoerceInterfaceTableGeneration {
}
fn (_ Zzz_CoerceInterfaceTableGeneration) write(buf []byte) ?int {
return none
}
fn (_ Zzz_CoerceInterfaceTableGeneration) read(mut buf []byte) ?int {
return none
}
fn zzz_reader_writer_coerce_compiler() {

View File

@ -89,6 +89,7 @@ pub fn (c TcpConn) read_ptr(buf_ptr byteptr, len int) ?int {
} else {
wrap_error(code) ?
}
return none
}
pub fn (c TcpConn) read(mut buf []byte) ?int {

View File

@ -5165,13 +5165,6 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
node.stmts << ast.Return{
pos: node.pos
}
} else {
node.stmts << ast.Return{
pos: node.pos
exprs: [ast.Expr(ast.None{
pos: node.pos
})]
}
}
}
c.stmts(node.stmts)

View File

@ -1,7 +1,7 @@
vlib/v/checker/tests/unknown_generic_type.vv:5:13: error: unknown type `Foo`
3 |
4 | fn main() {
5 | x := decode<Foo>('{"name": "test"}')?
vlib/v/checker/tests/unknown_generic_type.vv:6:13: error: unknown type `Foo`
4 |
5 | fn main() {
6 | x := decode<Foo>('{"name": "test"}')?
| ~~~~~
6 | println(x)
7 | }
7 | println(x)
8 | }

View File

@ -1,4 +1,5 @@
fn decode<T>(raw_data string) ?T {
return none
}
fn main() {

View File

@ -177,6 +177,7 @@ pub fn (mut pc PkgConfig) extend(pcdep &PkgConfig) ?string {
pc.libs_private << lib
}
}
return none
}
fn (mut pc PkgConfig) load_requires() {

View File

@ -327,6 +327,7 @@ fn get_string(param bool) ?string {
if param {
return 'Hello World'
}
return none
}
fn test_option_auto_add_return_none() {

View File

@ -24,6 +24,7 @@ fn (mut ws Client) socket_read(mut buffer []byte) ?int {
}
}
}
return none
}
// socket_read reads from socket into the provided byte pointer and length
@ -47,6 +48,7 @@ fn (mut ws Client) socket_read_ptr(buf_ptr byteptr, len int) ?int {
}
}
}
return none
}
// socket_write writes the provided byte array to the socket

View File

@ -177,6 +177,7 @@ pub fn (mut ws Client) read_next_message() ?Message {
}
return msg
}
return none
}
// payload_from_fragments returs the whole paylaod from fragmented message