parser: use `?` instead of `?void` errpr
parent
b0f66a4e05
commit
1386c5df13
|
@ -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 | }
|
|
@ -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