Created
September 12, 2013 07:46
-
-
Save m2ym/6534131 to your computer and use it in GitHub Desktop.
for (...) { var a = ...; f(function() { return a; }); } みたいな危険なキャプチャを検出するルール
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dangerous_capture(Ident) :- | |
for_body(ForBody), | |
stmt_child(ForBody, stmt, VarStmt), | |
statement(VarStmt, var, Var, _, _), | |
var(Var, Decls), | |
var_decls(Decls, D), | |
var_decl(D, VarName, _, _, _), | |
stmt_desc(ForBody, expr, FuncExpr), | |
expression(FuncExpr, function, Func, _, _), | |
function(Func, _, _, FuncBody), | |
statements(FuncBody, FuncStmt), | |
stmt_desc(FuncStmt, expr, IdentExpr), | |
expression(IdentExpr, ident, Ident, _, _), | |
ident(Ident, VarName). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment