mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: use ?
instead of ?void
errpr
This commit is contained in:
parent
b0f66a4e05
commit
1386c5df13
5
vlib/v/checker/tests/void_optional_err.out
Normal file
5
vlib/v/checker/tests/void_optional_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/void_optional_err.v:1:16: error: use `?` instead of `?void`
|
||||
1 | fn ret_void() ?void {
|
||||
| ~~~~
|
||||
2 | return error('error')
|
||||
3 | }
|
7
vlib/v/checker/tests/void_optional_err.vv
Normal file
7
vlib/v/checker/tests/void_optional_err.vv
Normal file
@ -0,0 +1,7 @@
|
||||
fn ret_void() ?void {
|
||||
return error('error')
|
||||
}
|
||||
|
||||
fn main() {
|
||||
_ := ret_void() or { panic('$err') }
|
||||
}
|
@ -134,7 +134,11 @@ pub fn (mut p Parser) parse_type() table.Type {
|
||||
}
|
||||
mut typ := table.void_type
|
||||
if p.tok.kind != .lcbr {
|
||||
pos := p.tok.position()
|
||||
typ = p.parse_any_type(language, nr_muls > 0)
|
||||
if typ == table.void_type {
|
||||
p.error_with_pos('use `?` instead of `?void`', pos)
|
||||
}
|
||||
}
|
||||
if is_optional {
|
||||
typ = typ.set_flag(.optional)
|
||||
|
@ -274,7 +274,7 @@ fn test_multi_return_opt() {
|
||||
}
|
||||
}
|
||||
*/
|
||||
fn foo() ?void {
|
||||
fn foo() ? {
|
||||
return error('something')
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user