-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
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
逗号表达式处理 else for 语法时候取不到body bug #1
Comments
好的,这个我会检查一下,因为在这之前应该有个修复if else的block的模块,可以将没有被block包裹的部分用block包裹起来,你可以尝试在执行[VariableDeclaratorFix之前先行执行一下IfWithExpressFix |
IfWithExpressFix 做了两种类型的判断 isExpressionStatement isReturnStatement 不晓得这里是否有特殊情况 我直接改成了 if (types.isIfStatement(node)){
if (node.consequent != null && !types.isBlockStatement(node.consequent)){
path.node.consequent = types.blockStatement([node.consequent])
}
else if(node.consequent === null){
path.node.consequent = types.blockStatement([])
}
if (node.alternate != null && !types.isBlockStatement(node.alternate)){
path.node.alternate = types.blockStatement([node.alternate])
}
} 在我处理的代码里面 可以运行。 |
好的,我看看
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ast_tools/libs/common/VariableDeclaratorFix.js
Line 68 in cf3bca8
这段代码在处理逗号表达式的时候,如果碰到 else for 这种写法 由于else 的内容没有用大括号包裹, 会导致在拿for的父对象的body 插 AssignmentExpression 的时候 取不到 body 导致报错, 感觉应该对所有的 else 都先对 alternate 检查 如果 不是 BlockStatement
都加上一个BlockStatement 包裹住
下面为测试代码
if (void 0 !== e[r(n(1163, 1110))]) { u = r(""); } else for (var f = [r("ESEAPx0Y"), r(n(1230, 1247)), r("Czc"), r("CQ")], v = 0; v < f[r(n(1346, 1251))]; v++) { if (void 0 !== e[f[v] + r("Li0GMBEC")]) { u = f[v]; break; } }
The text was updated successfully, but these errors were encountered: