diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp index d7c04eb5f11fc0d49e48d660b2edf7b7a529a9d9..b103584bb152b54190120319bf664e3dc69300a5 100644 --- a/src/libs/qmljs/qmljscheck.cpp +++ b/src/libs/qmljs/qmljscheck.cpp @@ -255,13 +255,18 @@ bool Check::visit(UiScriptBinding *ast) return false; } - IdentifierExpression *idExp = cast<IdentifierExpression *>(expStmt->expression); - if (! idExp) { + QString id; + if (IdentifierExpression *idExp = cast<IdentifierExpression *>(expStmt->expression)) { + id = idExp->name->asString(); + } else if (StringLiteral *strExp = cast<StringLiteral *>(expStmt->expression)) { + id = strExp->value->asString(); + warning(loc, QCoreApplication::translate("QmlJS::Check", "using string literals for ids is discouraged")); + } else { error(loc, QCoreApplication::translate("QmlJS::Check", "expected id")); return false; } - if (! idExp->name->asString()[0].isLower()) { + if (id.isEmpty() || ! id[0].isLower()) { error(loc, QCoreApplication::translate("QmlJS::Check", "ids must be lower case")); return false; }