Details
-
Sub-task
-
Resolution: Invalid
-
P4: Low
-
None
-
None
Description
This behavior is tested by tst_QScriptContext::argumentsObjectInNative().
static QScriptValue fun(QScriptContext *ctx, QScriptEngine *eng) { return eng->evaluate("arguments[0]"); } ... QScriptEngine eng; eng.globalObject().setProperty("fun", eng.newFunction(fun)); qDebug() << eng.evaluate("fun(123)").toString(); // should print "123"
Rationale:
The QtScript doc says (http://doc.trolltech.com/4.7/qscriptengine.html): "[QScriptEngine::evaluate()] is the C++ equivalent of the built-in script function eval()".
Compare to this JS program:
function fun() { return eval("arguments[0]"); } fun(123); // returns 123
Hence, the native behavior is consistent.
So long as QScriptEngine::evaluate() evaluates the script in the current context (as opposed to in the global context), this behavior should be unsurprising.
However, this behavior isn't supported by neither JavaScriptCore nor V8 "out of the box".