-
Notifications
You must be signed in to change notification settings - Fork 119
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
Fix SyntaxError due to function declarations #109
base: master
Are you sure you want to change the base?
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.