Merge pull request #70 from urbit/eamsden/fix-cut

jets: fix cut for 0 run
This commit is contained in:
Edward Amsden 2023-08-29 07:48:00 -05:00 committed by GitHub
commit 08f14b8318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -543,6 +543,10 @@ pub fn jet_cut(stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
let run = raw_slot(arg, 13).as_direct()?.data() as usize;
let atom = raw_slot(arg, 7).as_atom()?;
if run == 0 {
return Ok(D(0));
}
let new_indirect = unsafe {
let (mut new_indirect, new_slice) =
IndirectAtom::new_raw_mut_bitslice(stack, ((run << bloq) + 63) >> 6);
@ -1225,6 +1229,9 @@ mod tests {
fn test_cut() {
let s = &mut init();
let (_a0, a24, _a63, a96, a128) = atoms(s);
let run = T(s, &[D(0), D(0)]);
let sam = T(s, &[D(0), run, a24]);
assert_jet(s, jet_cut, sam, D(0));
let run = T(s, &[D(0), D(5)]);
let sam = T(s, &[D(0), run, a24]);
assert_jet(s, jet_cut, sam, D(0x3));