Skip to content

Commit

Permalink
checker: disallow thread as var name (#19174)
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 authored Aug 25, 2023
1 parent 45e6e7d commit 11337e7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub const (
array_builtin_methods_chk = token.new_keywords_matcher_from_array_trie(array_builtin_methods)
// TODO: remove `byte` from this list when it is no longer supported
reserved_type_names = ['byte', 'bool', 'char', 'i8', 'i16', 'int', 'i64', 'u8', 'u16',
'u32', 'u64', 'f32', 'f64', 'map', 'string', 'rune', 'usize', 'isize', 'voidptr']
'u32', 'u64', 'f32', 'f64', 'map', 'string', 'rune', 'usize', 'isize', 'voidptr', 'thread']
reserved_type_names_chk = token.new_keywords_matcher_from_array_trie(reserved_type_names)
vroot_is_deprecated_message = '@VROOT is deprecated, use @VMODROOT or @VEXEROOT instead'
)
Expand Down
6 changes: 6 additions & 0 deletions vlib/v/checker/tests/thread_as_var_name_err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vlib/v/checker/tests/thread_as_var_name_err.vv:1:1: warning: unused variable: `thread`
1 | thread := 4
| ~~~~~~
vlib/v/checker/tests/thread_as_var_name_err.vv:1:1: error: invalid use of reserved type `thread` as a variable name
1 | thread := 4
| ~~~~~~
1 change: 1 addition & 0 deletions vlib/v/checker/tests/thread_as_var_name_err.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
thread := 4
4 changes: 2 additions & 2 deletions vlib/v/tests/go_wait_3_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fn test_method_go_wait() {
test: 'hi'
}
}
thread := spawn a.sub.get()
r := thread.wait()
t := spawn a.sub.get()
r := t.wait()
assert r == 'hi'
}

Expand Down

0 comments on commit 11337e7

Please sign in to comment.