From 423ccd84379a6d8af647f76ed4bddac767230f17 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 13 Oct 2009 15:22:05 +1000 Subject: Library importing requires a version. Fix and test. --- src/declarative/qml/qmlscriptparser.cpp | 12 ++++++++++-- .../qmllanguage/data/importVersionMissingBuiltIn.errors.txt | 2 +- .../data/importVersionMissingInstalled.errors.txt | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 57e40b6..c45bdcc 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -294,7 +294,7 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, if (isScript) { if (_stateStack.isEmpty() || _stateStack.top().property) { QmlError error; - error.setDescription(QLatin1String("Invalid use of Script block")); + error.setDescription(QCoreApplication::translate("QmlParser","Invalid use of Script block")); error.setLine(typeLocation.startLine); error.setColumn(typeLocation.startColumn); _parser->_errors << error; @@ -474,7 +474,7 @@ bool ProcessAST::visit(AST::UiImport *node) import.qualifier = node->importId->asString(); if (!import.qualifier.at(0).isUpper()) { QmlError error; - error.setDescription(QLatin1String("Invalid import qualifier ID")); + error.setDescription(QCoreApplication::translate("QmlParser","Invalid import qualifier ID")); error.setLine(node->importIdToken.startLine); error.setColumn(node->importIdToken.startColumn); _parser->_errors << error; @@ -483,6 +483,14 @@ bool ProcessAST::visit(AST::UiImport *node) } if (node->versionToken.isValid()) import.version = textAt(node->versionToken); + else if (import.type == QmlScriptParser::Import::Library) { + QmlError error; + error.setDescription(QCoreApplication::translate("QmlParser","Library import requires a version")); + error.setLine(node->importIdToken.startLine); + error.setColumn(node->importIdToken.startColumn); + _parser->_errors << error; + return false; + } import.location = location(startLoc, endLoc); import.uri = uri; diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt b/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt index 2235cbc..c7d880e 100644 --- a/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/importVersionMissingBuiltIn.errors.txt @@ -1 +1 @@ -SHOULD GIVE AN ERROR ABOUT MISSING VERSION +1:16:Library import requires a version diff --git a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt b/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt index 2235cbc..89e58ee 100644 --- a/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/importVersionMissingInstalled.errors.txt @@ -1 +1 @@ -SHOULD GIVE AN ERROR ABOUT MISSING VERSION +1:35:Library import requires a version -- cgit v0.12 From 278b97494dbeed4be391caf32537fd19f19f0186 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 13 Oct 2009 15:34:14 +1000 Subject: Stop crash (stop on error) --- src/declarative/qml/qmlscriptparser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index c45bdcc..9cc12b3 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -298,6 +298,7 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, error.setLine(typeLocation.startLine); error.setColumn(typeLocation.startColumn); _parser->_errors << error; + return 0; } } -- cgit v0.12