002 array literal imported type

✓ Passing This code compiles and runs correctly.

Code

// ============================================================================
// BUG 991: Array Literals with Imported Types Use Invalid Syntax
// ============================================================================
//
// Issue: When creating array literals in flows using types from imported
// modules, the generated Zig uses `:` syntax which is invalid.
//
// Expected Zig:  &[_]koru_mylib.Handle{ h1, h2 }
// Actual Zig:    &[_]mylib:Handle{ h1, h2 }    ❌ INVALID! (':' is not Zig)
//
// This affects creating arrays/slices of imported types in flow arguments.
//
// Discovered while building $std/threading library (test 2006)
// ============================================================================

const std = @import("std");
~import $std/threading

// Create some handles
~event makeHandle { id: u64 }
| made { handle: threading:WorkerHandle }

~proc makeHandle {
    // Create a dummy handle (just for testing codegen)
    const handle = threading:WorkerHandle{
        .thread = undefined,
        .result_ptr = undefined,
    };
    return .{ .made = .{ .handle = handle } };
}

// Event that accepts array of handles
~event joinHandles { handles: []const threading:WorkerHandle }
| joined {}

~proc joinHandles {
    return .{ .joined = .{} };
}

// Try to use array literal with imported type
~makeHandle(id: 1)
| made h1 |> makeHandle(id: 2)
    | made h2 |> joinHandles(handles: &[_]threading:WorkerHandle{ h1.handle, h2.handle })
        | joined |> _
input.kz

Error Verification

Actual Compiler Output

[PHASE 2.4] Calling run_pass for transforms\n[PHASE 2.5] Executing comptime_main() - running comptime flows
[PHASE 2.5] Comptime flows complete (39 items)
[PHASE 2.6] Rescanning transformed AST (39 items)
[PHASE 2.6] Rescan complete: 25 comptime events found
  [0] std.compiler:requires
  [1] std.compiler:flag.declare
  [2] std.compiler:command.declare
  [3] std.compiler:coordinate
  [4] std.compiler:context_create
  [5] std.testing:test
  [6] std.testing:validate_mocks
  [7] std.testing:test.with_harness
  [8] std.testing:test.harness
  [9] std.testing:assert
  [10] std.testing:test.property.equivalent
  [11] std.deps:deps
  [12] std.deps:requires.system
  [13] std.deps:requires.zig
  [14] std.control:if
  [15] std.control:for
  [16] std.control:capture
  [17] std.control:const
  [18] std.build:requires
  [19] std.build:variants
  [20] std.build:config
  [21] std.build:command.sh
  [22] std.build:command.zig
  [23] std.build:step
  [24] std.template:define

[PHANTOM-KORU] Starting phantom check proc...
[DEAD-STRIP] Removing event_decl: std.compiler:coordinate
[DEAD-STRIP] Removing event_decl: std.compiler:ast_dump
[DEAD-STRIP] Removing proc_decl: std.compiler:ast_dump
[DEAD-STRIP] Removing event_decl: std.compiler:transform_taps
[DEAD-STRIP] Removing proc_decl: std.compiler:transform_taps
[DEAD-STRIP] Removing event_decl: std.compiler:parse
[DEAD-STRIP] Removing proc_decl: std.compiler:parse
[DEAD-STRIP] Removing event_decl: std.threading:worker.spawn
[DEAD-STRIP] Removing proc_decl: std.threading:worker.spawn
[DEAD-STRIP] Removing event_decl: std.threading:worker.spawn.async
[DEAD-STRIP] Removing proc_decl: std.threading:worker.spawn.async
[DEAD-STRIP] Removing event_decl: std.threading:worker.spawn.await
[DEAD-STRIP] Removing proc_decl: std.threading:worker.spawn.await
[DEAD-STRIP] Removing event_decl: std.threading:worker.spawn.join
[DEAD-STRIP] Removing proc_decl: std.threading:worker.spawn.join
[DEAD-STRIP] Removing event_decl: std.testing:test
[DEAD-STRIP] Removing proc_decl: std.testing:test
[DEAD-STRIP] Removing event_decl: std.testing:test.with_harness
[DEAD-STRIP] Removing event_decl: std.testing:test.harness
[DEAD-STRIP] Removing event_decl: std.testing:assert
[DEAD-STRIP] Removing proc_decl: std.testing:assert
[DEAD-STRIP] Removing event_decl: std.testing:assert.ok
[DEAD-STRIP] Removing proc_decl: std.testing:assert.ok
[DEAD-STRIP] Removing event_decl: std.testing:assert.fail
[DEAD-STRIP] Removing proc_decl: std.testing:assert.fail
[DEAD-STRIP] Removing event_decl: std.testing:assert.eq
[DEAD-STRIP] Removing event_decl: std.testing:assert.contains
[DEAD-STRIP] Removing event_decl: std.testing:test.property.equivalent
[DEAD-STRIP] Removing event_decl: std.deps:deps
[DEAD-STRIP] Removing proc_decl: std.deps:deps
[DEAD-STRIP] Removing event_decl: std.deps:requires.zig
[DEAD-STRIP] Removing proc_decl: std.deps:requires.zig
[DEAD-STRIP] Removing event_decl: std.control:if
[DEAD-STRIP] Removing proc_decl: std.control:if
[DEAD-STRIP] Removing event_decl: std.control:for
[DEAD-STRIP] Removing proc_decl: std.control:for
[DEAD-STRIP] Removing event_decl: std.control:capture
[DEAD-STRIP] Removing proc_decl: std.control:capture
[DEAD-STRIP] Removing event_decl: std.control:const
[DEAD-STRIP] Removing proc_decl: std.control:const
[DEAD-STRIP] Removing event_decl: std.build:requires
[DEAD-STRIP] Removing proc_decl: std.build:requires
[DEAD-STRIP] Removing event_decl: std.build:variants
[DEAD-STRIP] Removing proc_decl: std.build:variants
[DEAD-STRIP] Removing event_decl: std.build:config
[DEAD-STRIP] Removing proc_decl: std.build:config
[DEAD-STRIP] Removing event_decl: std.build:command.sh
[DEAD-STRIP] Removing event_decl: std.build:command.zig
[DEAD-STRIP] Removing event_decl: std.build:command
[DEAD-STRIP] Removing event_decl: std.build:collect
[DEAD-STRIP] Removing proc_decl: std.build:collect
[DEAD-STRIP] Removing event_decl: std.compiler_types:__compiler_types_marker
[DEAD-STRIP] Stripped 52 unreachable items

[BUFFER DEBUG] After CodeEmitter.init:
[BUFFER DEBUG]   code_emitter.pos = 0
[BUFFER DEBUG]   First 50 bytes: [170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170][170]

[BUFFER DEBUG] After visitor_emitter.emit:
[BUFFER DEBUG]   code_emitter.pos = 8897
[BUFFER DEBUG]   First 50 bytes of buffer: // Access compiler flags from backend.zig via root
[BUFFER DEBUG] final_code length = 8897
[BUFFER DEBUG]   First 50 bytes of final_code: // Access compiler flags from backend.zig via root


[INTER] inter:start called with 6 contexts
[INTER] --inter flag not set, skipping
🎯 Compiler coordination: Passes: 13 (flow-based: frontend, analysis, emission)

[MAIN DEBUG] Before file write:
[MAIN DEBUG]   generated_code.len = 8897
[MAIN DEBUG]   generated_code.ptr = u8@10ab54010
[MAIN DEBUG]   emitted_file = output_emitted.zig
[MAIN DEBUG]   emitted_file.ptr = u8@10453845e
[MAIN DEBUG]   First 50 bytes: // Access compiler flags from backend.zig via root

Error: output_emitted.zig:37:41: error: expected ';' after statement
                const handle = threading:WorkerHandle{
                                        ^

Test Configuration

MUST_FAIL