✓
Passing This code compiles and runs correctly.
Code
// TEST: Array literal must target a slice type
//
// Koru array literal syntax ([a, b, c]) is only valid when the target
// parameter is a slice (e.g. []const i32). Using it for a non-slice
// parameter must fail.
~event take { numbers: i32 }
~proc take|zig {
return .{ .done = {} };
}
~take(numbers: [1, 2, 3])
Must contain:
ArrayLiteralInvalidTargetError Verification
Expected Error Pattern
Array literal must target a slice type
This test MUST FAIL to ensure array literals only apply to slice parameters.
Expected error: array literal used for non-slice field (numbers: i32).
If this test passes, the compiler is accepting untyped/invalid array literals.Actual Compiler Output
thread 93139898 panic: attempt to unwrap error: ArrayLiteralInvalidTarget
/Users/larsde/src/koru/src/emitter_helpers.zig:9307:9: 0x102f08b83 in emitArrayLiteralForField (backend)
return error.ArrayLiteralInvalidTarget;
^
/Users/larsde/src/koru/src/emitter_helpers.zig:6304:21: 0x102f05deb in emitArgs (backend)
try emitArrayLiteralForField(emitter, ctx, field_info, arg.value);
^
/Users/larsde/src/koru/src/emitter_helpers.zig:5900:5: 0x102f0daab in emitInvocation (backend)
try emitArgs(emitter, ctx, invocation.args, &invocation.path);
^
/Users/larsde/src/koru/src/emitter_helpers.zig:4591:13: 0x102f441a3 in emitFlow (backend)
try emitInvocation(emitter, ctx, flow.inv(), binding);
^
/Users/larsde/src/koru/src/visitor_emitter.zig:1332:17: 0x102f8d967 in visitItem (backend)
try emitter.emitFlow(self.code_emitter, &ctx, &flow);
^
/Users/larsde/src/koru/src/visitor_emitter.zig:644:13: 0x102fac0d3 in emit (backend)
try self.visitItem(item, source_file.module_annotations, source_file.items);
^
/Users/larsde/src/koru/tests/regression/000_CORE_LANGUAGE/030_LITERALS/030_014_array_literal_invalid_target/backend_output_emitted.zig:1298:57: 0x102e0638f in handler (backend)
visitor_emitter.emit(ctx.ast) catch unreachable;
^
/Users/larsde/src/koru/tests/regression/000_CORE_LANGUAGE/030_LITERALS/030_014_array_literal_invalid_target/backend_output_emitted.zig:1172:102: 0x102dfeb3f in handler (backend)
const nested_result_1 = koru_std.koru_compiler.emit_zig_event.handler(.{ .ctx = c2 });
^
/Users/larsde/src/koru/tests/regression/000_CORE_LANGUAGE/030_LITERALS/030_014_array_literal_invalid_target/backend_output_emitted.zig:721:126: 0x102dfd36f in handler (backend)
const nested_result_4 = koru_std.koru_compiler.emission_event.handler(.{ .ctx = c4 });
^
/Users/larsde/src/koru/tests/regression/000_CORE_LANGUAGE/030_LITERALS/030_014_array_literal_invalid_target/backend_output_emitted.zig:5644:67: 0x102dfcfb7 in koru_coordinate (backend)
const result = koru_std.koru_compiler.coordinate_event.handler(.{
^
/Users/larsde/src/koru/tests/regression/000_CORE_LANGUAGE/030_LITERALS/030_014_array_literal_invalid_target/backend.zig:91:39: 0x102d8b913 in emit (backend)
const result = koru_coordinate(source_ast, &allocator);
^
/Users/larsde/src/koru/tests/regression/000_CORE_LANGUAGE/030_LITERALS/030_014_array_literal_invalid_target/backend.zig:202:51: 0x102d8c6db in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^
/opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/std/start.zig:627:37: 0x102d92367 in main (backend)
const result = root.main() catch |err| {
^
???:?:?: 0x1894ffdff in ??? (???)
???:?:?: 0x0 in ??? (???)
/Users/larsde/src/koru/scripts/regression_lib.sh: line 341: 93707 Abort trap: 6 ./backend outputFlows
flow ~take click a branch to expand · @labels scroll to their anchor
take (numbers: [1, 2, 3])
Test Configuration
MUST_FAIL