fix: SET 原始值接收者按严格性分流并补脏重建本体标

This commit is contained in:
2026-09-24 19:37:26 +00:00
parent f9e6eb3b2b
commit 4787f2180f
9 changed files with 56 additions and 30 deletions
+12 -2
View File
@@ -102,9 +102,19 @@ fn test_to_int32_and_to_uint32() {
}
#[test]
fn primitive_property_write_throws_clean_type_error() {
fn primitive_property_write_sloppy_auto_boxes() {
// sloppy 模式:原始值接收者 auto-box,写盒后丢弃盒,不抛 TypeError。
for source in ["'abc'.x = 1", "(5).foo = 1", "true.foo = 1"] {
let err = eval(source);
let result = eval(source);
assert_eq!(result, "1", "sloppy auto-box should return 1 for {source}, got {result}");
}
}
#[test]
fn primitive_property_write_strict_throws_clean_type_error() {
// strict 模式:原始值接收者抛 clean TypeError(非内部 opcode 消息)。
for source in ["'abc'.x = 1", "(5).foo = 1", "true.foo = 1"] {
let err = eval(&format!("\"use strict\"; {source}"));
assert!(err.contains("TypeError"), "expected TypeError for {source}, got {err}");
assert!(
!err.contains("IC_SET_PROP on non-object")