fix: 将同步原生调用参数限制错误消息对齐 ECMAScript 规范措辞
This commit is contained in:
@@ -252,10 +252,7 @@ impl Vm {
|
|||||||
&mut self, receiver: JsValue, callee: JsValue, args: &[JsValue],
|
&mut self, receiver: JsValue, callee: JsValue, args: &[JsValue],
|
||||||
) -> Result<Vec<u8>, String> {
|
) -> Result<Vec<u8>, String> {
|
||||||
if args.len() > Self::SYNC_NATIVE_ARG_LIMIT {
|
if args.len() > Self::SYNC_NATIVE_ARG_LIMIT {
|
||||||
return Err(format!(
|
return Err("RangeError: Maximum call stack size exceeded".to_string());
|
||||||
"RangeError: synchronous native call supports at most {} arguments",
|
|
||||||
Self::SYNC_NATIVE_ARG_LIMIT
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.regs[253] = receiver;
|
self.regs[253] = receiver;
|
||||||
@@ -1450,7 +1447,7 @@ mod tests {
|
|||||||
.call_function_sync(callee, JsValue::undefined(), &args)
|
.call_function_sync(callee, JsValue::undefined(), &args)
|
||||||
.expect_err("too many args should fail cleanly");
|
.expect_err("too many args should fail cleanly");
|
||||||
|
|
||||||
assert!(err.contains("at most 253 arguments"), "unexpected error: {err}");
|
assert!(err.contains("Maximum call stack size exceeded"), "unexpected error: {err}");
|
||||||
assert_eq!(vm.reg(1), JsValue::int(7));
|
assert_eq!(vm.reg(1), JsValue::int(7));
|
||||||
assert_eq!(vm.reg(253), JsValue::int(11));
|
assert_eq!(vm.reg(253), JsValue::int(11));
|
||||||
assert_eq!(vm.reg(254), JsValue::int(12));
|
assert_eq!(vm.reg(254), JsValue::int(12));
|
||||||
|
|||||||
Reference in New Issue
Block a user