checker: add support for apk comptime if (#13079)

pull/13080/head
Larpon 2022-01-07 12:38:21 +01:00 committed by GitHub
parent 6e6d51a1c9
commit 7276705684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -24,7 +24,7 @@ const (
valid_comptime_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
valid_comptime_if_platforms = ['amd64', 'i386', 'aarch64', 'arm64', 'arm32', 'rv64', 'rv32']
valid_comptime_if_cpu_features = ['x64', 'x32', 'little_endian', 'big_endian']
valid_comptime_if_other = ['js', 'debug', 'prod', 'test', 'glibc', 'prealloc',
valid_comptime_if_other = ['apk', 'js', 'debug', 'prod', 'test', 'glibc', 'prealloc',
'no_bounds_checking', 'freestanding', 'threads', 'js_node', 'js_browser', 'js_freestanding',
'interpreter', 'es5']
valid_comptime_not_user_defined = all_valid_comptime_idents()

View File

@ -528,6 +528,7 @@ fn (mut c Checker) comptime_if_branch(cond ast.Expr, pos token.Position) bool {
return false
} else if cname in valid_comptime_if_other {
match cname {
'apk' { return !c.pref.is_apk }
'js' { return !c.pref.backend.is_js() }
'debug' { return !c.pref.is_debug }
'prod' { return !c.pref.is_prod }