mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: peek returns nth element from the top of the stack (#5262)
This commit is contained in:
@ -280,6 +280,7 @@ impl StackObj {
|
||||
.length(0)
|
||||
.build();
|
||||
|
||||
// peek returns the nth-from-the-top element of the stack.
|
||||
let peek = FunctionObjectBuilder::new(
|
||||
context,
|
||||
NativeFunction::from_copy_closure_with_captures(
|
||||
@ -293,6 +294,9 @@ impl StackObj {
|
||||
),
|
||||
)))
|
||||
}
|
||||
// idx is from the top of the stack, so we need to reverse it
|
||||
// SAFETY: bounds checked above
|
||||
let idx = len - idx - 1;
|
||||
stack_arr.get(idx as u64, ctx)
|
||||
},
|
||||
stack_arr,
|
||||
|
||||
Reference in New Issue
Block a user