checker: enable -skip-unused for more examples
parent
8f160ee3ed
commit
d30f94507c
|
@ -213,6 +213,9 @@ pub fn (mut c Checker) check_files(ast_files []ast.File) {
|
|||
c.error('a _test.v file should have *at least* one `test_` function', token.Position{})
|
||||
}
|
||||
}
|
||||
if c.pref.skip_unused {
|
||||
c.mark_used(ast_files)
|
||||
}
|
||||
// Make sure fn main is defined in non lib builds
|
||||
if c.pref.build_mode == .build_module || c.pref.is_test {
|
||||
return
|
||||
|
@ -227,9 +230,6 @@ pub fn (mut c Checker) check_files(ast_files []ast.File) {
|
|||
} else if !has_main_fn {
|
||||
c.error('function `main` must be declared in the main module', token.Position{})
|
||||
}
|
||||
if c.pref.skip_unused {
|
||||
c.mark_used(ast_files)
|
||||
}
|
||||
}
|
||||
|
||||
// do checks specific to files in main module
|
||||
|
|
|
@ -85,6 +85,21 @@ fn (mut c Checker) mark_used(ast_files []ast.File) {
|
|||
c.table.used_fns['main.main'] = true
|
||||
c.table.used_fns['builtin_init'] = true
|
||||
c.table.used_fns['memdup'] = true
|
||||
c.table.used_fns['vstring'] = true
|
||||
c.table.used_fns['vstring_with_len'] = true
|
||||
c.table.used_fns['string'] = true // array.string
|
||||
// c.table.used_fns['str'] = true // builtin .str() methods; They use strings.builder and strconv.ftoa_64 etc.
|
||||
// whitelist common modules const initializers too:
|
||||
c.table.used_fns['os.getwd'] = true
|
||||
c.table.used_fns['os.init_os_args'] = true
|
||||
//
|
||||
c.table.used_fns['term.can_show_color_on_stdin'] = true
|
||||
c.table.used_fns['term.can_show_color_on_stdout'] = true
|
||||
c.table.used_fns['term.can_show_color_on_stderr'] = true
|
||||
//
|
||||
c.table.used_fns['main.can_use_relative_paths'] = true
|
||||
//
|
||||
// eprintln('>>> c.table.used_fns: $c.table.used_fns')
|
||||
// c.timing_measure(@FN)
|
||||
|
||||
// println(walker.used_fns)
|
||||
|
|
Loading…
Reference in New Issue