Skip to content
Snippets Groups Projects
Commit feacbf8a authored by Christian Kamm's avatar Christian Kamm
Browse files

Check that the id property is a plain lowercase identifier.

parent 0e268533
No related branches found
No related tags found
No related merge requests found
......@@ -144,6 +144,32 @@ void Check::errorOnWrongRhs(const SourceLocation &loc, const Value *lhsValue)
bool Check::visit(UiScriptBinding *ast)
{
// special case for id property
if (ast->qualifiedId->name->asString() == QLatin1String("id") && ! ast->qualifiedId->next) {
if (! ast->statement)
return false;
const SourceLocation loc = locationFromRange(ast->statement->firstSourceLocation(),
ast->statement->lastSourceLocation());
ExpressionStatement *expStmt = cast<ExpressionStatement *>(ast->statement);
if (!expStmt) {
error(loc, QCoreApplication::translate("QmlJS::Check", "expected id"));
return false;
}
IdentifierExpression *idExp = cast<IdentifierExpression *>(expStmt->expression);
if (! idExp) {
error(loc, QCoreApplication::translate("QmlJS::Check", "expected id"));
return false;
}
if (! idExp->name->asString()[0].isLower()) {
error(loc, QCoreApplication::translate("QmlJS::Check", "ids must be lower case"));
return false;
}
}
const Value *lhsValue = checkScopeObjectMember(ast->qualifiedId);
if (lhsValue) {
// ### Fix the evaluator to accept statements!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment