feat: 间接 eval 读全局词法环境镜像并补齐写路径

This commit is contained in:
2026-10-16 15:03:55 +00:00
parent 84900dc4a1
commit cf0b59d892
18 changed files with 250 additions and 31 deletions
@@ -25,6 +25,11 @@ impl CompilerService for DefaultCompilerService {
fn compile_eval_script(&self, source: &str) -> Result<CompiledModule, String> {
oxide_parser::with_parse_allocator(|allocator| {
let program = parse_program(allocator, source)?;
// eval 代码是脚本:import/export 声明不得出现(规范 Script 产生式),
// 按模块解析命中即 SyntaxError(既有包装臂转成 JS 异常)。
if program.source_type.is_module() {
return Err("eval code may not contain import or export declarations".to_string());
}
// eval 脚本:顶层 var/function 声明落全局属性 configurable:true。
Compiler::new()
.with_eval_script(true)