✓
Passing This code compiles and runs correctly.
Code
// Layer 2 demonstration (event derivation, positive case):
// an event with a [pure] proc impl derives is_pure=true on
// the event itself. The event doesn't carry an annotation —
// purity is computed from impls.
const std = @import("std");
~event compute { x: i32 }
| result i32
~[pure] proc compute|zig {
return .{ .result = x * 2 };
}
~event main {}
~compute(x: 21)
| result _ |> _
Test Configuration
MUST_RUN
Post-validation Script:
#!/bin/bash
# Verify: event with [pure] proc impl derives is_pure=true on the
# event declaration itself. Layer 2: event purity is computed from
# impl purity (AND across impls).
if [ ! -f "backend.zig" ]; then
echo "✗ backend.zig not found"
exit 1
fi
# AST literal moved from backend.zig to program_ast.zig (split landed 2026-05-20).
# Concatenate both so grep -n / sed -n by line number still work.
cat backend.zig program_ast.zig 2>/dev/null > _combined_emit.zig
# Find the event declaration for compute
EVENT_LINE=$(grep -n 'event_decl = EventDecl' _combined_emit.zig | while read line; do
linenum=$(echo "$line" | cut -d: -f1)
if sed -n "$((linenum)),$((linenum + 5))p" _combined_emit.zig | grep -q '"compute"'; then
echo "$linenum"
break
fi
done)
if [ -z "$EVENT_LINE" ]; then
echo "✗ Could not find compute event_decl"
exit 1
fi
EVENT=$(sed -n "$((EVENT_LINE)),$((EVENT_LINE + 40))p" _combined_emit.zig)
if echo "$EVENT" | grep -q 'is_pure = true'; then
echo "✓ compute event: is_pure = true (derived from pure proc impl)"
else
echo "✗ FAIL: compute event should be is_pure = true (derived from ~[pure] proc impl)"
exit 1
fi
if echo "$EVENT" | grep -q 'is_transitively_pure = true'; then
echo "✓ compute event: is_transitively_pure = true (derived)"
else
echo "✗ FAIL: compute event should be is_transitively_pure = true"
exit 1
fi
echo ""
echo "✓ Event correctly derives is_pure=true from its pure proc impl"
exit 0