✓
Passing This code compiles and runs correctly.
Code
// Test (negative): passing a bare `f32` (no phantom label) where `f32[celsius]`
// is required must be rejected by the phantom semantic checker.
//
// Safety counterpart to 330_063_phantom_state_on_primitive — that test proves
// matching phantoms compile and a conversion event transitions across labels;
// this one proves that an un-labelled f32 can't masquerade as a labelled one.
~event read-raw { sensor_id: u8 }
| reading f32 // BARE f32 — no phantom label
~read-raw => reading 22.5
~event to-fahrenheit { c: f32<celsius> } // requires [celsius]
| result f32<fahrenheit>
~to-fahrenheit => result c * 9.0 / 5.0 + 32.0
~read-raw(sensor_id: 1)
| reading t |> to-fahrenheit(c: t) // ERROR: f32 cannot satisfy f32[celsius]
| result _ |> _
Must fail at runtime:
Program must error when executed.
Error Verification
Actual Compiler Output
error[KORU030]: Phantom state mismatch: argument 'c' has no tracked phantom state, but event requires '<celsius>'. The value must be in state 'input:celsius'.
--> phantom_semantic_check:19:0
❌ Compiler coordination error: Phantom semantic validation failed
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_064_reject_phantom_primitive_mismatch/backend.zig:94:13: 0x104caa3b3 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_064_reject_phantom_primitive_mismatch/backend.zig:190:28: 0x104cab09f in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Test Configuration
MUST_FAIL
Expected Error:
Phantom state mismatch: argument 'c' has no tracked phantom state