Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.3.2
-
None
Description
You cannot evaluate an anonymous function directly, it yields a syntax error but the expected result is true wrapped in a QJSValue. Note the function call directly after the function declaration.
Code to reproduce the error:
QJSEngine engine; QJSValue result = engine.evaluate("function(){return true}()"); if (result.isError()) { qWarning("%s", qPrintable(result.toString())); }
Output:
SyntaxError: unexpected token
It works fine if I surround the function declaration with parenthesis, but other engines support the other way, though:
(function(){return true})();