1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ast: disallow threads << go fn()?{} and threads << go fn()!{} (fix #16061) (#16064)

This commit is contained in:
shove 2022-10-14 00:37:27 +08:00 committed by GitHub
parent f0108323d1
commit 51a9e89c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -975,6 +975,8 @@ pub fn (t &Table) thread_name(return_type Type) string {
if return_type.idx() == void_type_idx {
if return_type.has_flag(.optional) {
return 'thread ?'
} else if return_type.has_flag(.result) {
return 'thread !'
} else {
return 'thread'
}
@ -991,6 +993,8 @@ pub fn (t &Table) thread_cname(return_type Type) string {
if return_type == void_type {
if return_type.has_flag(.optional) {
return '__v_thread_Option_void'
} else if return_type.has_flag(.result) {
return '__v_thread_Result_void'
} else {
return '__v_thread'
}

View File

@ -0,0 +1,7 @@
vlib/v/checker/tests/go_append_optional_to_threads_err.vv:5:12: error: cannot append `thread !` to `[]thread`
3 | fn main() {
4 | mut ths := []thread{}
5 | ths << go foo()
| ~~~~~
6 | ths.wait()
7 | }

View File

@ -0,0 +1,7 @@
fn foo() ! {}
fn main() {
mut ths := []thread{}
ths << go foo()
ths.wait()
}