feat: Reflect.has 切统一数值键门并修 2^32 索引边界

This commit is contained in:
2026-09-23 11:13:56 +00:00
parent c0f8970912
commit f199cd9632
3 changed files with 166 additions and 4 deletions
+2 -2
View File
@@ -11,12 +11,12 @@ use oxide_runtime_api::{NativeResult, VmHost};
use crate::builtins_debug;
/// 判断字符串是否为规范整数索引:非空、无前导零、全数字且值 < 2^32-1。
/// 判断字符串是否为规范整数索引:非空、无前导零、全数字且值 < 2^32。
fn is_integer_index(key: &str) -> bool {
if key.is_empty() || key.len() > 1 && key.as_bytes()[0] == b'0' {
return false;
}
key.bytes().all(|b| b.is_ascii_digit()) && key.parse::<u64>().unwrap_or(u64::MAX) < (1u64 << 32) - 1
key.bytes().all(|b| b.is_ascii_digit()) && key.parse::<u64>().unwrap_or(u64::MAX) < (1u64 << 32)
}
/// 收集对象全部自身属性(数组元素区 + shape 链),按规范顺序排列:整数索引在前