seqc/error_flag_lint.rs
1//! Error Flag Detection (Phase 2b)
2//!
3//! Abstract stack simulation that tracks Bool values produced by fallible
4//! operations. Warns when these "error flags" are dropped without being
5//! checked via `if` or `cond`.
6//!
7//! This catches patterns that the TOML-based pattern linter misses:
8//! - `file.slurp swap nip` (Bool moved by swap, then dropped by nip)
9//! - `i./ >aux ... aux> drop` (Bool stashed on aux stack, dropped later)
10//!
11//! # Architecture
12//!
13//! Modeled on `resource_lint.rs`:
14//! 1. Tag Bools from fallible ops with their origin
15//! 2. Simulate stack operations to track tag movement
16//! 3. When a tagged Bool is consumed by `if`/`cond`, mark checked
17//! 4. When consumed by `drop`/`nip`/other, emit warning
18//!
19//! # Conservative Design
20//!
21//! - Only tracks Bools from known fallible builtins (not all Bools)
22//! - If a tagged Bool flows into an unknown user word, assume checked
23//! (avoids false positives from cross-word analysis)
24//! - Bools remaining on the stack at word end are assumed returned
25//! (escape analysis, same as resource_lint)
26
27mod analyzer;
28mod state;
29
30#[cfg(test)]
31mod tests;
32
33pub use analyzer::ErrorFlagAnalyzer;