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

parser: fix case of falsely registering imports as used, remove unused imports #21156

Merged
merged 7 commits into from
Apr 1, 2024

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Apr 1, 2024

Fixes e.g,

import term as te
import te.ui // alias `te` as part of another import would register the import `term` as used, despite its never being used.

fn main() {}

The change reveals a lot of unused imports that are removed in this PR as a requirement to pass CI.

@ttytm ttytm force-pushed the parser/fix-used-imports branch 2 times, most recently from b7844d2 to 80d40d6 Compare April 1, 2024 02:34
@ttytm ttytm linked an issue Apr 1, 2024 that may be closed by this pull request
@JalonSolov
Copy link
Contributor

In this particular case, I'd think it would report both term and term.ui as being unused.

Will that happen with this change?

@ttytm
Copy link
Member Author

ttytm commented Apr 1, 2024

There is a test added that correctly recognizes them as not being used

import term as te
import te.ui
vlib/v/checker/tests/unused_import_err.vv:1:8: warning: module 'te (term)' is imported but never used
    1 | import term as te
      |        ~~~~
    2 | import te.ui
vlib/v/checker/tests/unused_import_err.vv:2:8: warning: module 'ui (te.ui)' is imported but never used
    1 | import term as te
    2 | import te.ui
      |        ~~~~~
vlib/v/checker/tests/unused_import_err.vv:2:1: builder error: cannot import module "te.ui" (not found)
    1 | import term as te
    2 | import te.ui
      | ~~~~~~~~~~~~

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.

@spytheman spytheman merged commit 9704a01 into vlang:master Apr 1, 2024
53 of 54 checks passed
@ttytm ttytm deleted the parser/fix-used-imports branch April 1, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unclear Error on Importing Submodule From Aliased Module
3 participants