feat: 支持 this 语法

This commit is contained in:
爱特每羊队
2026-06-07 23:07:50 +08:00
parent 005b4659f9
commit 501a14b3af
4 changed files with 65 additions and 0 deletions
@@ -358,3 +358,21 @@ fn compile_compound_member_exp_ok() {
});
assert!(result.is_ok(), "obj.x**=2 should compile without error");
}
#[test]
fn compile_this_in_function_ok() {
let module = compile_source("function f() { return this; }");
assert!(!module.bytecode.is_empty());
}
#[test]
fn compile_this_member_assign_ok() {
let module = compile_source("function f() { this.x = 1; }");
assert!(!module.bytecode.is_empty());
}
#[test]
fn compile_this_member_read_ok() {
let module = compile_source("function f() { return this.x; }");
assert!(!module.bytecode.is_empty());
}