@@ -12,6 +12,7 @@ import v.util
12
12
import v.util.version
13
13
import v.errors
14
14
import v.pkgconfig
15
+ import v.checker.constants
15
16
16
17
const (
17
18
int_min = int (0x80000000 )
@@ -23,37 +24,16 @@ const (
23
24
)
24
25
25
26
pub const (
26
- valid_comptime_if_os = ['windows' , 'ios' , 'macos' , 'mach' , 'darwin' , 'hpux' , 'gnu' ,
27
- 'qnx' , 'linux' , 'freebsd' , 'openbsd' , 'netbsd' , 'bsd' , 'dragonfly' , 'android' , 'termux' ,
28
- 'solaris' , 'haiku' , 'serenity' , 'vinix' ]
29
- valid_comptime_compression_types = ['none' , 'zlib' ]
30
- valid_comptime_if_compilers = ['gcc' , 'tinyc' , 'clang' , 'mingw' , 'msvc' , 'cplusplus' ]
31
- valid_comptime_if_platforms = ['amd64' , 'i386' , 'aarch64' , 'arm64' , 'arm32' , 'rv64' , 'rv32' ]
32
- valid_comptime_if_cpu_features = ['x64' , 'x32' , 'little_endian' , 'big_endian' ]
33
- valid_comptime_if_other = ['apk' , 'js' , 'debug' , 'prod' , 'test' , 'glibc' , 'prealloc' ,
34
- 'no_bounds_checking' , 'freestanding' , 'threads' , 'js_node' , 'js_browser' , 'js_freestanding' ,
35
- 'interpreter' , 'es5' , 'profile' , 'wasm32_emscripten' ]
36
- valid_comptime_not_user_defined = all_valid_comptime_idents ()
37
- array_builtin_methods = ['filter' , 'clone' , 'repeat' , 'reverse' , 'map' , 'slice' ,
38
- 'sort' , 'contains' , 'index' , 'wait' , 'any' , 'all' , 'first' , 'last' , 'pop' ]
39
- array_builtin_methods_chk = token.new_keywords_matcher_from_array_trie (array_builtin_methods)
27
+ array_builtin_methods = ['filter' , 'clone' , 'repeat' , 'reverse' , 'map' , 'slice' , 'sort' ,
28
+ 'contains' , 'index' , 'wait' , 'any' , 'all' , 'first' , 'last' , 'pop' ]
29
+ array_builtin_methods_chk = token.new_keywords_matcher_from_array_trie (array_builtin_methods)
40
30
// TODO: remove `byte` from this list when it is no longer supported
41
- reserved_type_names = ['byte' , 'bool' , 'char' , 'i8' , 'i16' , 'int' , 'i64' , 'u8' ,
42
- 'u16' , ' u32' , 'u64' , 'f32' , 'f64' , 'map' , 'string' , 'rune' ]
43
- reserved_type_names_chk = token.new_keywords_matcher_from_array_trie (reserved_type_names)
44
- vroot_is_deprecated_message = '@VROOT is deprecated, use @VMODROOT or @VEXEROOT instead'
31
+ reserved_type_names = ['byte' , 'bool' , 'char' , 'i8' , 'i16' , 'int' , 'i64' , 'u8' , 'u16 ' ,
32
+ 'u32' , 'u64' , 'f32' , 'f64' , 'map' , 'string' , 'rune' ]
33
+ reserved_type_names_chk = token.new_keywords_matcher_from_array_trie (reserved_type_names)
34
+ vroot_is_deprecated_message = '@VROOT is deprecated, use @VMODROOT or @VEXEROOT instead'
45
35
)
46
36
47
- fn all_valid_comptime_idents () []string {
48
- mut res := []string {}
49
- res << checker.valid_comptime_if_os
50
- res << checker.valid_comptime_if_compilers
51
- res << checker.valid_comptime_if_platforms
52
- res << checker.valid_comptime_if_cpu_features
53
- res << checker.valid_comptime_if_other
54
- return res
55
- }
56
-
57
37
[heap; minify]
58
38
pub struct Checker {
59
39
pref & pref.Preferences = unsafe { nil } // Preferences shared from V struct
@@ -1644,7 +1624,7 @@ fn (mut c Checker) stmt(node_ ast.Stmt) {
1644
1624
for i, ident in node.defer_vars {
1645
1625
mut id := ident
1646
1626
if mut id.info is ast.IdentVar {
1647
- if id.comptime && id.name in checker .valid_comptime_not_user_defined {
1627
+ if id.comptime && id.name in constants .valid_comptime_not_user_defined {
1648
1628
node.defer_vars[i] = ast.Ident{
1649
1629
scope: 0
1650
1630
name: ''
0 commit comments