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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve edge cases in dead code analysis #5902

Open
IGI-111 opened this issue Apr 23, 2024 · 2 comments
Open

Resolve edge cases in dead code analysis #5902

IGI-111 opened this issue Apr 23, 2024 · 2 comments

Comments

@IGI-111
Copy link
Contributor

IGI-111 commented Apr 23, 2024

No description provided.

@jjcnn
Copy link
Contributor

jjcnn commented Apr 26, 2024

One such edge case, regarding aliased imports:

wiz.sw

library;

pub struct Wiz {
    pub wiz: u64,
}

main.sw

script;
// This tests importing other files.

mod wiz;

use wiz::Wiz as WizWiz;

struct Wiz { 
    local_wiz: bool
}

fn main() -> u64 {
    let wiz = WizWiz {
	wiz: 128
    };
    let local_wiz = Wiz { // This should resolve to the locally defined Wiz
	local_wiz: true
    };
    if local_wiz.local_wiz {
	wiz.wiz
    }
    else {
	0
    }
}

The declaration of wiz::Wiz is reported as dead, even thought it is used in main.sw. Also, it's public so it probably shouldn't be reported as dead in the first place.

The above code can be found in test/src/e2e_vm_tests/test_programs/should_pass/language/aliased_imports, which also tests a number of other things regarding aliases. For the time being I'm disabling the dead code analysis for the struct.

@jjcnn
Copy link
Contributor

jjcnn commented May 8, 2024

Same problem in test/src/e2e_vm_tests/test_programs/should_pass/language/import_star_name_clash.

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

No branches or pull requests

2 participants