use crate::executor::VirtualMachine;
use shape_runtime::context::ExecutionContext;
use shape_value::heap_value::HeapKind;
use shape_value::{KindedSlot, NativeKind, VMError};
#[cold]
#[inline(never)]
fn ckpt3_surface(op: &'static str, args: &[KindedSlot]) -> VMError {
let receiver_kind = if args.is_empty() {
"<no args>".to_string()
} else {
format!("{:?}", args[0].kind)
};
VMError::NotImplemented(format!(
"{op}: SURFACE — V3-S5 ckpt-3 consumer-cascade tier 2 surface. \
`TypedArrayData` enum DELETED at ckpt-1 (2026-05-15) per W12-\
typed-array-data-deletion audit §3.5 + ADR-006 §2.7.24 Q25.A \
SUPERSEDED. The previous `Arc<TypedArrayData>` receiver-recovery \
+ per-variant element-dispatch path (~38 references across 19 \
public handlers in this file) and the `IteratorSource::Array \
(Arc<TypedArrayData>)` carrier variant in `shape_value::\
iterator_state` cascade-broke at the enum deletion site \
(`crates/shape-value/src/heap_value.rs:3944`). Post-deletion \
target is the v2-raw `TypedArray<T>` flat-struct carrier per \
audit §1.2 + §A.3 + §3.1 scalar recipe + §2.2 heap-element \
variants + ADR-006 §2.7.16 / Q17 lazy iterator carrier; per-T \
monomorphization landing across ckpt-3 (this file plus \
array_ops/typed_array_methods/array_sort/concat/property_access/\
array_query) + ckpt-4 (Buf<T> / HeapValue::TypedArray \
arm / HeapKind::TypedArray ordinal / shape-value iterator_state.rs \
IteratorSource::Array variant) + ckpt-5 (wire/json/marshal + \
4-table lockstep) + ckpt-6 (JIT FFI). Closure-callback ABI \
(ADR-006 §2.7.11 / Q12 `vm.call_value_immediate_nb`) is \
unaffected and re-instates once receiver-shape migration lands. \
Receiver kind: {kind}. UNREACHABLE until ckpt-6 STRICT close. \
REFUSED ON SIGHT: TypedArrayData resurrection under any rename \
(Refusal #1, W12 audit §7).",
op = op,
kind = receiver_kind,
))
}
#[inline]
fn validate_closure_arg(op: &str, args: &[KindedSlot]) -> Option<VMError> {
if args.len() >= 2 && args[1].kind != NativeKind::Ptr(HeapKind::Closure) {
Some(VMError::RuntimeError(format!(
"{}: second argument must be a closure, got kind {:?}",
op, args[1].kind
)))
} else {
None
}
}
pub fn v2_range_iter(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Range.iter", args))
}
pub(crate) fn handle_array_iter(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Array.iter", args))
}
pub(crate) fn handle_string_iter(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("String.iter", args))
}
pub(crate) fn handle_range_iter(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Range.iter", args))
}
pub(crate) fn handle_hashmap_iter(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("HashMap.iter", args))
}
pub(crate) fn handle_map(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
if let Some(err) = validate_closure_arg("Iterator.map", args) {
return Err(err);
}
Err(ckpt3_surface("Iterator.map", args))
}
pub(crate) fn handle_filter(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
if let Some(err) = validate_closure_arg("Iterator.filter", args) {
return Err(err);
}
Err(ckpt3_surface("Iterator.filter", args))
}
pub(crate) fn handle_take(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Iterator.take", args))
}
pub(crate) fn handle_skip(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Iterator.skip", args))
}
pub(crate) fn handle_flat_map(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
if let Some(err) = validate_closure_arg("Iterator.flatMap", args) {
return Err(err);
}
Err(ckpt3_surface("Iterator.flatMap", args))
}
pub(crate) fn handle_enumerate(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Iterator.enumerate", args))
}
pub(crate) fn handle_chain(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Iterator.chain", args))
}
pub(crate) fn handle_collect(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Iterator.collect", args))
}
pub(crate) fn handle_for_each(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
if let Some(err) = validate_closure_arg("Iterator.forEach", args) {
return Err(err);
}
Err(ckpt3_surface("Iterator.forEach", args))
}
pub(crate) fn handle_reduce(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Iterator.reduce", args))
}
pub(crate) fn handle_count(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
Err(ckpt3_surface("Iterator.count", args))
}
pub(crate) fn handle_any(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
if let Some(err) = validate_closure_arg("Iterator.any", args) {
return Err(err);
}
Err(ckpt3_surface("Iterator.any", args))
}
pub(crate) fn handle_all(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
if let Some(err) = validate_closure_arg("Iterator.all", args) {
return Err(err);
}
Err(ckpt3_surface("Iterator.all", args))
}
pub(crate) fn handle_find(
_vm: &mut VirtualMachine,
args: &[KindedSlot],
_ctx: Option<&mut ExecutionContext>,
) -> Result<KindedSlot, VMError> {
if let Some(err) = validate_closure_arg("Iterator.find", args) {
return Err(err);
}
Err(ckpt3_surface("Iterator.find", args))
}