Kida 0.2.1
Dead code elimination and filter partial evaluation
Released: February 14, 2026
Compiler improvements: dead code elimination for provably constant branches, and filter/pipeline partial evaluation whenstatic_contextis provided.
Highlights
- Dead code elimination — Const-only pass removes branches whose conditions are provably constant
- Filter partial evaluation — Pure filters evaluated at compile time when
static_contextis available - Scoping preserved — Skips inlining when block-scoped nodes (Set, Let, Capture, Export) are present
Added
Dead Code Elimination
A const-only pass removes branches whose conditions are provably constant at compile time:
{% if false %}
This block is never emitted
{% end %}
{% if 1+1==2 %}
This block is always emitted (condition folded away)
{% end %}
- Runs without
static_context— no runtime data needed - Skips inlining when the body contains block-scoped nodes (Set, Let, Capture, Export) to preserve scoping semantics
- Reduces bytecode size and eliminates unreachable branches
Filter/Pipeline Partial Evaluation
Whenstatic_contextis provided, the partial evaluator now evaluates Filter and Pipeline nodes for pure filters:
{{ site.title | default("Home") }}
{{ site.title | upper }}
- Uses built-in pure filters plus
Environment.pure_filters - Static expressions become literal strings in bytecode
- Eliminates per-render dictionary lookups for site-wide constants
Upgrade Guide
- No breaking changes — All existing templates continue to work unchanged
- Optional optimization — Provide
static_contextwhen compiling to enable filter partial evaluation - Dead code removal — Templates with
{% if false %}or similar will have those branches stripped automatically