✓
Passing This code compiles and runs correctly.
Code
// Test: Does ~log.error match the glob pattern log.* ?
//
// This test verifies that invocations can match glob pattern events:
// - ~log.error(...) should match the glob event log.*
// - The transform should run and replace the invocation
//
// The transform replaces the invocation with a simple inline print.
// Glob pattern transform event - matches any log.* invocation
~[comptime|transform]pub event log.* {
expr: Expression,
item: *const Item,
program: *const Program,
}
| transformed SiteResult
// Transform proc - replaces invocation with inline comment
~proc log.*|zig {
const ast = @import("ast");
const allocator = @import("std").heap.page_allocator;
// Get the flow from the item
const flow = if (item.* == .flow) &item.flow else return .{ .transformed = .{} };
// Create inline code to replace the flow (simple comment, no keywords)
const inline_code_item = ast.Item{
.inline_code = .{
.code = "// glob transform ran",
.location = flow.location,
.module = allocator.dupe(u8, flow.module) catch return .{ .transformed = .{} },
},
};
return .{ .transformed = .{ .replacement = inline_code_item } };
}
// This invocation should match log.* glob pattern
~log.error("Something went wrong")