Fix SyntaxError due to function declarations#109
Fix SyntaxError due to function declarations#109christofferqa wants to merge 1 commit intoSamsung:masterfrom
Conversation
|
@christofferqa can you also add a regression test for this issue? |
70de912 to
8f7d55e
Compare
|
@msridhar Added a test case that fails with the current master branch: |
8f7d55e to
3ba8c61
Compare
|
what is es2015? |
|
ECMAScript 2015. I added the test case to show that the current version of Jalangi throws a SyntaxError for code that is not syntactically correct itself (the instrumented program is, though). I have come across this issue after using Jalangi to instrument some of the most popular libraries for web applications. |
|
Jalangi only supports ES5. It cannot handle any later version.
|
|
@ksen007 reading #107 I think the issue is that Jalangi-instrumented code that might have worked in previous browser versions no longer works, due to changes in the browsers related to ES2015. @christofferqa is that right? |
|
@msridhar Yes, that is the case. Since the browsers are now implementing ES2015, Jalangi introduces a SyntaxError on certain code. Try to instrument this simple program using Jalangi, and run the instrumented program in Chrome: |
|
This patch breaks functions that redefine themselves. Simple test case: With your patch applied, this sends Jalangi off into an infinite loop (since _test is never redefined) While this may seem like an obscure testcase, is is perfectly valid syntax and unfortunately used e.g. by babel to polyfill the |
|
This is really weird and I do not fully understand it, but it seems that modern JS engines have trouble redefining named functions. I am not set up to provide a formal patch to your PR, but if I remove assigning a name to the generated function ( I guess assigning a name to the function literal is not really necessary, at least my tests all run correctly after the change. |
See #107.