mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-05-25 10:12:40 +08:00
u8 is too small for 256!
This commit is contained in:
@@ -5,7 +5,7 @@ use vm::errors::{Error, InterpreterResult as Result};
|
||||
use vm::types::{DefinedFunction, FunctionIdentifier, Value};
|
||||
use vm::database::ContractDatabase;
|
||||
|
||||
const MAX_CONTEXT_DEPTH: u8 = 256;
|
||||
const MAX_CONTEXT_DEPTH: u16 = 256;
|
||||
|
||||
pub struct Environment <'a> {
|
||||
pub global_context: Context <'a>,
|
||||
@@ -28,7 +28,7 @@ pub struct Context <'a> {
|
||||
pub parent: Option< &'a Context<'a>>,
|
||||
pub variables: HashMap<String, Value>,
|
||||
pub functions: HashMap<String, DefinedFunction>,
|
||||
depth: u8
|
||||
depth: u16
|
||||
}
|
||||
|
||||
impl <'a> Context <'a> {
|
||||
|
||||
@@ -47,20 +47,20 @@ fn test_bad_define_names() {
|
||||
fn test_stack_depth() {
|
||||
let mut function_defines = Vec::new();
|
||||
function_defines.push("(define (foo-0 x) (+ 1 x))".to_string());
|
||||
for i in 1..129 {
|
||||
for i in 1..257 {
|
||||
function_defines.push(
|
||||
format!("(define (foo-{} x) (foo-{} (+ 1 x)))",
|
||||
i, i-1));
|
||||
}
|
||||
function_defines.push(
|
||||
format!("(foo-127 1)"));
|
||||
format!("(foo-255 1)"));
|
||||
|
||||
let test0 = function_defines.join("\n");
|
||||
function_defines.push(
|
||||
format!("(foo-128 2)"));
|
||||
format!("(foo-256 2)"));
|
||||
let test1 = function_defines.join("\n");
|
||||
|
||||
assert_eq!(Ok(Value::Int(129)), execute(&test0));
|
||||
assert_eq!(Ok(Value::Int(257)), execute(&test0));
|
||||
assert_eq!(Err(Error::MaxStackDepthReached), execute(&test1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user