Skip to content

Commit

Permalink
checker: disallow incomplete thread struct fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Jun 28, 2024
1 parent 3ca6714 commit 32a5e4e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vlib/v/checker/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
c.warn('byte is deprecated, use u8 instead', field.type_pos)
}
}
.thread {
thread_type := sym.thread_info().return_type
if c.table.sym(thread_type).kind == .void {
c.error('`thread` needs to have a complete type like `thread int`, `thread []string`',
field.type_pos)
}
}
else {
c.check_any_type(field.typ, sym, field.type_pos)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vlib/v/checker/tests/struct_field_thread_incomplete_type_err.vv:2:4: error: `thread` needs to have a complete type like `thread int`, `thread []string`
1 | struct Str {
2 | t thread
| ~~~~~~
3 | a [0xF]bool
4 | }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
struct Str {
t thread
a [0xF]bool
}

0 comments on commit 32a5e4e

Please sign in to comment.