Skip to content

False Negative: RefCell dereference combined with immediate closure suppresses warnings. #39

@rikki322

Description

@rikki322

I have observed that MIRAI fails to report any warnings when a potential error depends on a value derived from RefCell inside an immediate closure.
Normally, using RefCell results in a "possible attempt" warning due to the uncertainty introduced by interior mutability. However, when this logic is wrapped in a closure (|| { ... })(), the warning is completely suppressed (total silence), rather than being reported as "possible".
To Reproduce

pub fn mul_overflows(cond: std::cell::RefCell<&bool>) -> u64 {
    let cond = **cond.borrow();
    (|| {
    let a: u64 = if cond { 0x8000000000000000 } else { 1 };
    a * 2 
})()
}
pub fn main() {
    mul_overflows(std::cell::RefCell::from(&(true)));
}

Expected Behavior
MIRAI should report a warning (likely possible attempt ...), consistent with the behavior when the code is not wrapped in a closure.
Actual Behavior
MIRAI reports zero warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions