021 template lookup in transform

○ Planned This feature is planned but not yet implemented.

Template-based code generation for ~if transform

Code

// Test: ~if uses REAL template system (lookupTemplate + interpolate)
//
// This test verifies that the ~if transform:
// 1. Calls template_utils.lookupTemplate(program, "if")
// 2. Finds the template defined in control.kz
// 3. Interpolates with ${condition}, ${| then |}, ${| else |}
// 4. Uses the result as inline_body
//
// This is ACTUAL template metaprogramming, not hardcoded string building!
// Mom can put this on the refrigerator.

~import "$std/io"

const std = @import("std");

const value = 42;

~if(value > 10)
| then |> std.io:println(text: "Template says: greater!")
| else |> std.io:println(text: "Template says: not greater!")
input.kz

Expected Output

Template says: greater!

Test Configuration

MUST_RUN

Post-validation Script:

#!/bin/bash
# Verify that ~if uses REAL template system

OUTPUT_FILE="output_emitted.zig"

# Check 1: No if_impl handler calls (excluding comments)
if grep -v "^[[:space:]]*//" "$OUTPUT_FILE" | grep -q "if_impl_event.handler"; then
    echo "FAIL: Found if_impl_event.handler - should use inline code"
    exit 1
fi

# Check 2: Has literal if statement with condition
if ! grep -qE "if \(value > 10\)" "$OUTPUT_FILE"; then
    echo "FAIL: Expected 'if (value > 10)' not found"
    exit 1
fi

# Check 3: Verify the template structure was used
# The template produces: if (${condition}) { ${| then |} } else { ${| else |} }
# So we should see the if/else structure with handler calls inside
if ! grep -q "println_event.handler" "$OUTPUT_FILE"; then
    echo "FAIL: Expected println handler calls not found"
    exit 1
fi

echo "PASS: ~if uses template-based code generation"
exit 0