Phase 2 Lint: Data flow analysis for resource leak detection #142
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq#142
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
The current lint system (Phase 1) uses syntactic pattern matching on word sequences. This works well for detecting simple inefficiencies like
swap swapordup drop, but cannot detect resource leaks that depend on control flow.PR #138 added simple weave lint rules:
weave-immediate-drop- catchesstrand.weave dropunchecked-resume- catchesstrand.resume drop drop dropThese catch obvious mistakes but miss more subtle leaks.
Problem: Patterns Can't Track Data Flow
Example 1: Leak through control flow
Pattern matching can't see that
dropin the else branch leaks the handle.Example 2: Leak across word boundaries
Example 3: Conditional completion
This is correct but pattern matching can't verify both branches handle the resource.
Proposed Solution: Phase 2 Data Flow Analysis
Architecture
Resource Definitions (Config)
Implementation Phases
Phase 2a: Single-word analysis
Phase 2b: Cross-word analysis
Phase 2c: Effect-based tracking
Yieldeffect must be used withstrand.weaveAlternative: Linear Types (Long-term)
A more principled solution would be linear/affine types:
This would be a type system change rather than a lint, providing compile-time guarantees.
Acceptance Criteria (Phase 2a MVP)
if/else/thenstrand.weaveandstrand.resumecompletion patternTest Cases
Related Issues
References
#[must_use]attributehttps://github.com/navicore/patch-seq/pull/159
https://github.com/navicore/patch-seq/pull/162