Skip to content

Add warning for unused imports #1298

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

Open
eureka-cpu opened this issue Apr 19, 2022 · 8 comments
Open

Add warning for unused imports #1298

eureka-cpu opened this issue Apr 19, 2022 · 8 comments
Labels
compiler: ui Mostly compiler messages DCA Everything to do with Dead Code Analysis good first issue Good for newcomers ODHack12 P: low team:compiler Compiler Team

Comments

@eureka-cpu
Copy link
Contributor

use foo::bar;
use baz::qux; <-- warning: unused import

fn main() {
    let bar = bar::new();
}
@eureka-cpu eureka-cpu changed the title Add warning for unused imports Add warning for unused imports Apr 19, 2022
@mitchmindtree
Copy link
Contributor

I plan to take a look into this following #1213 as a way to familiarise with dead code analysis, but won't assign to myself until then in case someone else wants to pick this up in the meantime.

@sezna
Copy link
Contributor

sezna commented May 21, 2022

I did some digging:

Dead code analysis is performed on the typed ast. We remove import statements from the typed AST and say they are SideEffects, or noops, during type checking. As the node is effectively removed from the tree, we no longer can add it to the graph for dead code analysis. In order to warn on unused imports, we need to transfer import statements into the typed tree. Then we can add them as a node to the control flow graph and connect to them if their defined content is ever used.

cc @mitchmindtree if you still plan on taking this one, your work in #1578 could end up impacting how import statements are represented and thusly could impact this issue.

@Oshioke-Salaki
Copy link

Can I contribute to this one? I am a well expereinced developer. eta 5hours

@manassehO
Copy link

Hi,

I’m Manasseh, and I’d like to take on this task! I’m a Rustacean with 3 years of experience and a strong grip on programming principles. Since this is a Sway compiler written in Rust, I can add a warning for unused imports like baz::qux in the example. I’ll make sure it’s clean, follows Rust standards, and helps developers spot issues fast. Let me handle this. I’ll do it solid and smart!

Thanks,

Manasseh

@ikemHood
Copy link

Can I work on this, please?

I understand that this is a compiler and this issue requires that I implement to display warnings for unused variables when compiling a sway program.

@cryptogru812
Copy link

Can I take this from here?

@FriendlyLifeguard
Copy link

Hello, could I work on this?

@saimeunt
Copy link
Contributor

Following up on my work on #7042 and #7043, I'd like to continue fixing issues on Sway, please assign me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: ui Mostly compiler messages DCA Everything to do with Dead Code Analysis good first issue Good for newcomers ODHack12 P: low team:compiler Compiler Team
Projects
None yet
Development

Successfully merging a pull request may close this issue.