mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Fix unqualified unused import false positive
If we exposed a symbol in an import and used it both unqualified and qualified, we'd produce an unused warning false positive. This happened because we were using a single bit flag to determine whether a value was used qualified or unqualified.
This commit is contained in:
parent
1f347f6ca1
commit
b56f029a09
2 changed files with 35 additions and 2 deletions
|
@ -47,6 +47,7 @@ impl ReferencesBitflags {
|
|||
const CALL: Self = ReferencesBitflags(4);
|
||||
const BOUND: Self = ReferencesBitflags(8);
|
||||
const QUALIFIED: Self = ReferencesBitflags(16);
|
||||
const UNQUALIFIED: Self = ReferencesBitflags(32);
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
@ -58,7 +59,7 @@ pub enum QualifiedReference {
|
|||
impl QualifiedReference {
|
||||
fn flags(&self, flags: ReferencesBitflags) -> ReferencesBitflags {
|
||||
match self {
|
||||
Self::Unqualified => flags,
|
||||
Self::Unqualified => ReferencesBitflags(flags.0 | ReferencesBitflags::UNQUALIFIED.0),
|
||||
Self::Qualified => ReferencesBitflags(flags.0 | ReferencesBitflags::QUALIFIED.0),
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +200,7 @@ impl References {
|
|||
let it = self.symbols.iter().zip(self.bitflags.iter());
|
||||
|
||||
for (a, b) in it {
|
||||
if *a == symbol && b.0 & mask > 0 && b.0 & ReferencesBitflags::QUALIFIED.0 == 0 {
|
||||
if *a == symbol && b.0 & mask > 0 && b.0 & ReferencesBitflags::UNQUALIFIED.0 > 0 {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue