QmlJS checks: Allow calling some builtin constructors as functions.

String, Boolean, Number and Object perform type conversion. Date returns
the current date.

Change-Id: I51e5bcbb0fa85ceb30b3ee3749f96c3e3b12ca21
Reviewed-on: http://codereview.qt-project.org/6043
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2011-10-05 13:51:10 +02:00
parent d48566234f
commit 03689eeb50
2 changed files with 10 additions and 1 deletions

View File

@@ -1173,7 +1173,12 @@ bool Check::visit(CallExpression *ast)
// check for capitalized function name being called
SourceLocation location;
const QString name = functionName(ast->base, &location);
if (!name.isEmpty() && name.at(0).isUpper()) {
if (!name.isEmpty() && name.at(0).isUpper()
&& name != QLatin1String("String")
&& name != QLatin1String("Boolean")
&& name != QLatin1String("Date")
&& name != QLatin1String("Number")
&& name != QLatin1String("Object")) {
addMessage(WarnExpectedNewWithUppercaseFunction, location);
}
if (cast<IdentifierExpression *>(ast->base) && name == QLatin1String("eval"))