Commit 03689eeb authored by Christian Kamm's avatar Christian Kamm
Browse files

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: default avatarFawzi Mohamed <fawzi.mohamed@nokia.com>
parent d4856623
......@@ -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"))
......
......@@ -11,5 +11,9 @@ Item {
function foo() {
a = A() // 306 13 13
a = a()
a = Number("abc")
a = String(12)
a = Boolean(12)
a = Date()
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment