-
Notifications
You must be signed in to change notification settings - Fork 686
Description
I was trying to put a code compiled with Emscripten and run them on both node.js and iot.js, however iot.js fails to parse a particular regular expression. After tracing the issue I think JerryScript is not-compliant with other ECMA Script implementations.
The line given by Emscripten is (matching a JavaScript function):
var sourceRegex = /^function\s*[a-zA-Z$_0-9]*\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
The minified code which produces a parsing error in jerryscript is:
var sourceRegex = /{}/;
On other JavaScript engines (like v8, node.js and the script console on my Firefox), the above minified code passed the parsing, while in JerryScript (and thus iot.js), it results in a parsing error.
Section 15.10 of ECMA262 seems to allow the above regular expression as the "{" (or "}" character) can be interpreted as an Atom instead of a start of QuantifierPrefix:
https://www.ecma-international.org/ecma-262/5.1/#sec-15.10