v0.8.18 — Constant Propagation Safety Fix
The Problem
v0.8.17 introduced a constant propagation optimizer pass that substitutes immutable variables with their literal values. Two edge cases broke safety checks that LOGOS relies on rustc to enforce.
String Propagation (E0382)
String is non-Copy in Rust. When the propagator substituted a string variable with its literal value, each use site got an independent String::from(...) allocation instead of a move. This meant rustc could no longer detect use-after-move errors:
Let s be "hello".
Let a be s.
Let b be s.
Before the fix, s was substituted away — both a and b got their own String::from("hello"), and the program compiled. After the fix, s remains as an identifier, rustc sees the double move, and reports E0382.
Zone Escape (E0597)
Zone-scoped variables were being propagated outside their zone. The escape checker treats Expr::Literal as always safe, so substituting a zone-scoped variable with its literal value hid the escape violation:
Let mutable leak be 0.
Zone "test" with capacity 100:
Let p be 42.
Set leak to p.
Before the fix, p was propagated to 42, and Set leak to 42 passed escape analysis. After the fix, zone-scoped bindings are not registered in the propagation environment, so p remains as an identifier and the escape checker correctly reports E0597.
The Fix
Two targeted changes in optimize/propagate.rs:
is_propagatable_literal— replacesis_literal, excludingLiteral::Textsince String is non-Copy in Rustpropagate_zone_block— processes zone bodies using the outer environment for substitution but does not register zone-scopedLetbindings, preventing them from leaking outward