mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
checker: warn on unused imported functions used via import math { sin, cos }
This commit is contained in:
parent
69e80ba96d
commit
61f91c263b
3 changed files with 16 additions and 0 deletions
|
@ -2853,6 +2853,9 @@ fn (mut c Checker) import_stmt(node ast.Import) {
|
|||
if !func.is_pub {
|
||||
c.error('module `${node.mod}` function `${sym.name}()` is private', sym.pos)
|
||||
}
|
||||
if func.usages != 1 {
|
||||
c.warn('module `${node.mod}` function `${sym.name}()` is unused', sym.pos)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if _ := c.file.global_scope.find_const(name) {
|
||||
|
|
10
vlib/v/checker/tests/import_sym_fn_unused_warning_err.out
Normal file
10
vlib/v/checker/tests/import_sym_fn_unused_warning_err.out
Normal file
|
@ -0,0 +1,10 @@
|
|||
vlib/v/checker/tests/import_sym_fn_unused_warning_err.vv:1:15: warning: module `math` function `sin()` is unused
|
||||
1 | import math { sin, cos }
|
||||
| ~~~
|
||||
2 |
|
||||
3 | fn main() {}
|
||||
vlib/v/checker/tests/import_sym_fn_unused_warning_err.vv:1:20: warning: module `math` function `cos()` is unused
|
||||
1 | import math { sin, cos }
|
||||
| ~~~
|
||||
2 |
|
||||
3 | fn main() {}
|
3
vlib/v/checker/tests/import_sym_fn_unused_warning_err.vv
Normal file
3
vlib/v/checker/tests/import_sym_fn_unused_warning_err.vv
Normal file
|
@ -0,0 +1,3 @@
|
|||
import math { sin, cos }
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue