Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single selective import will produce a warning "module is imported but never used" #23412

Open
khalyomede opened this issue Jan 8, 2025 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).

Comments

@khalyomede
Copy link
Contributor

khalyomede commented Jan 8, 2025

Describe the bug

When selectively importing a single statement inside of a module, a warning is raised.

Reproduction Steps

  1. Create a folder "http" and a file "http/Mime.v" with this content:
module http

enum Mime {
  text_html
}
  1. Create a "main.v" file and have this content:
module main

import http { Mime }

fn main() {
  mime := Mime.text_html.str()

  println(mime)
}

Interpret or compile the main file:

> v run main.v
main.v:3:8: warning: module 'http' is imported but never used
    1 | module main
    2 | 
    3 | import http { Mime }
      |        ~~~~
    4 | 
    5 | fn main() {
text_html

Expected Behavior

No warnings when selectively importing one module.

Current Behavior

It produce a warning when compiing or interpreting the code:

> v main.v
main.v:3:8: warning: module 'http' is imported but never used
    1 | module main
    2 | 
    3 | import http { Mime }
      |        ~~~~
    4 | 
    5 | fn main() {

Possible Solution

In the mean time I just import the module without selective import, and access my statement (see below).

Additional Information/Context

Simple module import produces no warnings when used in place of a single selective import. This code below will produce no warnings:

module main

import http

fn main() {
  mime := http.Mime.text_html.str()

  println(mime)
}

V version

0.4.9

Environment details (OS name and version, etc.)

V full version V 0.4.9 9fc8352
OS linux, N/A
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
Memory 6.8GB/15.43GB
V executable /opt/v/v
V last modified time 2025-01-08 03:26:40
V home dir OK, value: /opt/v
VMODULES OK, value: /root/.vmodules
VTMP OK, value: /tmp/v_0
Current working dir OK, value: /home/v
env VFLAGS "-cc gcc"
Git version git version 2.30.6
V git status 9fc8352 (3 commit(s) behind V master)
.git/config present true
cc version cc (Alpine 10.2.1_pre1) 10.2.1 20201203
gcc version gcc (Alpine 10.2.1_pre1) 10.2.1 20201203
clang version N/A
tcc version tcc version 0.9.27 mob:d3e940c (x86_64 Linux)
tcc git status thirdparty-linuxmusl-amd64 a3e24da2
emcc version N/A
glibc version Error: musl libc (x86_64)
Version 1.2.2
Dynamic Program Loader
Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname

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.

@khalyomede khalyomede added the Bug This tag is applied to issues which reports bugs. label Jan 8, 2025
@spytheman spytheman added Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones). Status: Confirmed This bug has been confirmed to be valid by a contributor. labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).
Projects
None yet
Development

No branches or pull requests

2 participants