module scheme import reader // The syntactic reader retains numeric spans. Validate their exact runtime // values before publishing the one owned byte buffer; no second numeric parser. fn read_bytevector_datum(doc &reader.Document, id reader.NodeId, path string) !Value { count := doc.arena.bytevector_length(id)! mut bytes := []u8{cap: count} for index in 0 .. count { item := doc.arena.bytevector_at(id, index)! occurrence := doc.arena.node(item)! canonical := doc.arena.node(doc.arena.canonical_id(item)!)! if canonical.kind != .number { return EvalError{ message: 'bytevector literal needs exact integers in 0..255', source_path: path, offset: occurrence.start, line: occurrence.line, column: occurrence.column } } number := parse_number(number_view(doc.arena.source_text(), canonical.start, canonical.end)) or { return EvalError{ message: err.msg(), source_path: path, offset: occurrence.start, line: occurrence.line, column: occurrence.column } } byte := byte_value(number) or { return EvalError{ message: err.msg(), source_path: path, offset: occurrence.start, line: occurrence.line, column: occurrence.column } } unsafe { (&u8(bytes.data))[index] = byte } } unsafe { bytes.len = count } return owned_bytevector(bytes) }