✓
Passing This code compiles and runs correctly.
Code
// Test: Custom Compiler Coordinator Override
//
// Validates that users can override the abstract coordinate event
// with their own pipeline implementation using cross-module overrides (~mod:event = ...).
//
// The custom coordinator prints a marker, then delegates to standard pipeline.
~import std/compiler
~import std/optimizer
const std = @import("std");
const ast = @import("ast");
const Program = ast.Program;
// Custom coordinator that wraps the default pipeline
// All compiler events must be module-qualified
~std/compiler:coordinate = custom-marker() |> std/compiler:context-create(program_ast, allocator)
| created c0 |> std/compiler:frontend(ctx: c0)
| ctx c1 |> std/compiler:transform-taps(ctx: c1)
| ctx c2 |> std/compiler:analysis(ctx: c2)
| ctx c3 |> std/compiler:test-generation(ctx: c3)
| ctx c4 |> std/optimizer:optimize(ctx: c4)
| ctx c5 |> std/compiler:emission(ctx: c5)
| ctx c6 => coordinated {
c6.ctx.ast,
c6.code,
metrics: "Custom coordinator ran!"
}
| failed f => error f.message
// Helper event to print marker (must be comptime since it's called from coordinate handler)
~[comptime] event custom-marker {}
~proc custom-marker|zig {
std.debug.print("CUSTOM COORDINATOR: Pipeline override active!\n", .{});
}
// Simple test event
~pub event hello {}
~proc hello|zig {
std.debug.print("Hello from custom-compiled code!\n", .{});
}
~hello()
Actual
Hello from custom-compiled code!
Test Configuration
MUST_RUN