We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jsjs/src/eval.ts
Line 183 in b0f6711
这里不应该是设置父级的作用域。
应该是设置for循环里的新作用域new_scope
new_scope
亲测, 下面这个例子跑不痛。
import test from "ava"; import * as fs from "fs"; import vm from "../src/vm"; test("ForInStatement-1", t => { const sandbox: any = vm.createContext({}); const obj: any = vm.runInContext( ` const obj = { 1: false, 2: false }; for (let attr in obj) { obj[attr] = true; } module.exports = obj; `, sandbox ); t.true(obj[1]); t.true(obj[2]); });
attr应该是 0、1,但实际上,永远是1,因为for循环里面的作用域没有attr变量。
0、1
只有父级作用域有attr,而且attr=1
The text was updated successfully, but these errors were encountered:
嗯,这是个 bug ……
Sorry, something went wrong.
No branches or pull requests
jsjs/src/eval.ts
Line 183 in b0f6711
这里不应该是设置父级的作用域。
应该是设置for循环里的新作用域
new_scope
亲测, 下面这个例子跑不痛。
attr应该是
0、1
,但实际上,永远是1,因为for循环里面的作用域没有attr变量。只有父级作用域有attr,而且attr=1
The text was updated successfully, but these errors were encountered: