Resolve edge cases in dead code analysis
IGI-111 opened this issue · comments
IGI-111 commented
jjcnn commented
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 commented
Same problem in test/src/e2e_vm_tests/test_programs/should_pass/language/import_star_name_clash
.