import : warning err
Describe the bug
import warning err
Reproduction Steps
log_project/strcuts/struct.v
module structs
import veb
pub struct Context {
veb.Context
}
log_project/middleware/logger.v
module middleware
import log
import structs { Context }
pub fn logger_middleware(mut ctx Context) bool {
log.info('[veb] trace_before_request: ${ctx.req.method} ${ctx.req.url}')
return true
}
log_project/main.v
module main
import veb
import structs { Context }
import middleware { logger_middleware }
pub struct App {
veb.Middleware[Context]
veb.Controller
veb.StaticHandler
}
pub fn main() {
mut app := &App{}
app.use(handler: logger_middleware)
port := 9009
veb.run_at[App, Context](mut app,
host: ''
port: port
family: .ip6
timeout_in_seconds: 30
) or { panic(err) }
}
Expected Behavior
no warning
Current Behavior
main.v:5:8: warning: module 'middleware' is imported but never used
3 | import veb
4 | import structs { Context }
5 | import middleware { logger_middleware }
| ~~~~~~~~~~
6 |
7 | pub struct App {
[veb] Running app on http://localhost:9009/
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.10 86536e4
Environment details (OS name and version, etc.)
| V full version | V 0.4.10 86536e452e6248056666c750668334c7da87202e.86536e4 |
|---|---|
| OS | linux, Deepin 23 |
| Processor | 6 cpus, 64bit, little endian, Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz |
| Memory | 0.17GB/7.61GB |
| V executable | /home/Jengro/.vmr/versions/v_versions/v_latest/v |
| V last modified time | 2025-03-31 00:44:37 |
| V home dir | OK, value: /home/Jengro/.vmr/versions/v_versions/v_latest |
| VMODULES | OK, value: /home/Jengro/.vmodules |
| VTMP | OK, value: /tmp/v_1000 |
| Current working dir | OK, value: /home/Jengro/Documents/Dev/v-product/vprod-workspase |
| Git version | git version 2.45.2 |
| V git status | weekly.2025.13-37-g86536e45 (5 commit(s) behind V master) |
| .git/config present | true |
| cc version | cc (Deepin 12.3.0-17deepin8) 12.3.0 |
| gcc version | gcc (Deepin 12.3.0-17deepin8) 12.3.0 |
| clang version | Deepin clang version 17.0.6 (5deepin5) |
| tcc version | tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux) |
| tcc git status | thirdparty-linux-amd64 696c1d84 |
| emcc version | N/A |
| glibc version | ldd (Debian GLIBC 2.38-6deepin7) 2.38 |
[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.
Connected to Huly®: V_0.6-22501
V 0.4.11 feb4090
The problem still exists
Here's how you can fix the warning:
-
import middleware -
app.use(handler: middleware.logger_middleware)
Someone else still needs to decide how to handle this condition. I can think of removing the warning or, maybe better being more strict and give a compile time error.
dto/user/user1.v
module user
pub struct User1 {
id string
}
pub fn user1() {
println('Hello, user 1!')
}
parts/user/user2.v
module user
pub struct User2 {
id string
}
pub fn user2() {
println('Hello, user 2!')
}
main.v
module main
import dto.user {User1}
import parts.user as user2 { User2 }
fn main() {
user.user1()
}
struct User {
id User1
id2 User2
}
main.v:4:8: warning: module 'user2 (parts.user)' is imported but never used
2 |
3 | import dto.user { User1 }
4 | import parts.user as user2 { User2 }
| ~~~~~~~~~~
5 |
6 | fn main() {
Hello, user 1!
Here's a simpler example, so I think it's right not to issue warnings
@fleximus @medvednikov