WALA
WALA copied to clipboard
On support of `let` in JavaScript analysis
If I use the JSCallGraphDriver under WALA-start to build a call graph for the following JS code
foo((a) => {
let b = "";
});
an exception with the following message will show
Exception in thread "main" com.ibm.wala.util.WalaException: front end errors:
error in test.js:
[SEVERE] missing ; before statement: test.js@2: let b = "";
end of front end errors
at com.ibm.wala.cast.util.Util.checkForFrontEndErrors(Util.java:36)
at com.ibm.wala.examples.analysis.js.JSCallGraphBuilderUtil.makeCG(JSCallGraphBuilderUtil.java:223)
at com.ibm.wala.examples.analysis.js.JSCallGraphBuilderUtil.makeScriptCGBuilder(JSCallGraphBuilderUtil.java:92)
at com.ibm.wala.examples.analysis.js.JSCallGraphBuilderUtil.makeScriptCG(JSCallGraphBuilderUtil.java:147)
at com.ibm.wala.examples.analysis.js.JSCallGraphBuilderUtil.makeScriptCG(JSCallGraphBuilderUtil.java:138)
at com.ibm.wala.examples.drivers.JSCallGraphDriver.main(JSCallGraphDriver.java:29)
If I remove the let keyword like this
foo((a) => {
b = "";
});
The output seems correct
3 = invoke 2@1 exception:4
6 = invoke 5@3 exception:7
7 = invoke 9@7 11,12 exception:13
Call graph stats:
Nodes: 108
Edges: 107
Methods: 4
Bytecode Bytes: 0
Since let keyword is common in real cases, can WALA fix this issue or how can I work around it?
You may use babel to downgrade the code.
@xiaofen9 Thanks for your solution. Yes it is a good idea.
We should support let if our JS parser Rhino exposes it in a proper way. It's not a huge departure from extant JS variables. Will look into it when I get some time, or contributions are welcome!