From 3b643ab873b12e7464cfcc67e55ce9c09feafa28 Mon Sep 17 00:00:00 2001 From: Alex Shelkovnykov Date: Wed, 15 Nov 2023 22:21:13 +0100 Subject: [PATCH] jets: fix mismatch between Arvo and Ares for +mook --- rust/ares/src/interpreter.rs | 15 ++++++++++----- rust/ares/src/jets/nock.rs | 8 +------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/rust/ares/src/interpreter.rs b/rust/ares/src/interpreter.rs index dfc39e1..6c306d9 100644 --- a/rust/ares/src/interpreter.rs +++ b/rust/ares/src/interpreter.rs @@ -1390,8 +1390,10 @@ mod hint { } tas!(b"hela") => { // XX: This only prints the trace down to the bottom of THIS - // interpret call. We'll need to recursively work down - // frames to get the stack trace all the way to the root. + // interpret call, making this neither a %nara nor a %hela + // hint, as Vere understands them. We'll need to + // recursively work down frames to get the stack trace all + // the way to the root. let mean = unsafe { *(context.stack.local_noun_pointer(0)) }; let tone = Cell::new(&mut context.stack, D(2), mean); @@ -1401,6 +1403,9 @@ mod hint { let newt = &mut context.newt; if unsafe { !toon.head().raw_equals(D(2)) } { + // +mook will only ever return a $toon with non-%2 head if that's what it was given as + // input. Since we control the input for this call exactly, there must exist a programming + // error in Ares if this occurs. panic!("serf: %hela: mook returned invalid tone"); } @@ -1422,9 +1427,9 @@ mod hint { } } Err(_) => { - let stack = &mut context.stack; - let tape = tape(stack, "serf: %hela: mook error"); - slog_leaf(stack, &mut context.newt, tape); + // +mook should only ever bail if the input is not [%2 (list)]. Since we control the input + // for this call exactly, there must exist a programming error in Ares if this occurs. + panic!("serf: unrecoverable stack trace error"); } } } diff --git a/rust/ares/src/jets/nock.rs b/rust/ares/src/jets/nock.rs index 108b63f..62101b1 100644 --- a/rust/ares/src/jets/nock.rs +++ b/rust/ares/src/jets/nock.rs @@ -194,13 +194,7 @@ pub mod util { let tag = tone.head().as_direct()?; let original_list = tone.tail(); - match tag.data() { - x if x < 2 => return Ok(tone), - x if x > 2 => return Err(JetErr::Fail(Error::Deterministic(D(0)))), - _ => {} - } - - if unsafe { original_list.raw_equals(D(0)) } { + if (tag.data() != 2) | unsafe { original_list.raw_equals(D(0)) } { return Ok(tone); } else if original_list.atom().is_some() { return Err(JetErr::Fail(Error::Deterministic(D(0))));