Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
4.6.0
-
None
Description
QScriptEngine eng;
qDebug() << eng.newRegExp(QRegExp("foo")).isFunction(); // returned false prior to 4.6
Similarly, the expression "typeof /foo/" returned "object" prior to 4.6, but now returns "function".
JavaScriptCore, like SpiderMonkey (FireFox) and V8 (Chrome), allows regular expressions objects to be called as functions, whereas the old QtScript back-end did not.
Technically, regular expression objects are callable, but they are not functions. Still, QScriptValue::isFunction() behaves like isCallable(), and that's really what it should have been called. (See also http://www.davidflanagan.com/2009/08/typeof-isfuncti.html)
If you want to treat regular expressions unlike other callable objects, since 4.6 you have to write e.g. object.isFunction() && !object.isRegExp().
Attachments
Issue Links
- is required for
-
QTBUG-16571 Resolve QtScript behavior that reflects implementation of old ("classic") back-end
-
- Closed
-