diff options
author | Erik Verbruggen <erik.verbruggen@me.com> | 2013-01-09 20:34:39 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-11 12:34:49 +0100 |
commit | 4dbbaf6814d327ec4b182325a8bab59314cfaf23 (patch) | |
tree | 1140db29b11fb360d017fef8cdae58517b94d1c3 | |
parent | ad008479ac13b60890eccb982355b90ff738be4e (diff) |
Make numeric-literal parsing more robust.
For cases where large non-fp numeric literals might end up triggering
coversion or rounding errors when stored as doubles when lexing.
This is a corner case, but it does trigger a case or two in the ECMA5
test suite (test262).
Change-Id: Ie6d355e28379aba9a339c4e345b5d2a0c32d5fdd
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | src/qml/qml/parser/qqmljslexer.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/literals.qml | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/src/qml/qml/parser/qqmljslexer.cpp b/src/qml/qml/parser/qqmljslexer.cpp index f31140a796..253526b714 100644 --- a/src/qml/qml/parser/qqmljslexer.cpp +++ b/src/qml/qml/parser/qqmljslexer.cpp @@ -891,7 +891,7 @@ again: int Lexer::scanNumber(QChar ch) { if (ch != QLatin1Char('0')) { - double integer = ch.unicode() - '0'; + quint64 integer = ch.unicode() - '0'; QChar n = _char; const QChar *code = _codePtr; diff --git a/tests/auto/qml/qqmllanguage/data/literals.qml b/tests/auto/qml/qqmllanguage/data/literals.qml index 9c6003dc40..462eb4c26d 100644 --- a/tests/auto/qml/qqmllanguage/data/literals.qml +++ b/tests/auto/qml/qqmllanguage/data/literals.qml @@ -8,6 +8,7 @@ QtObject { property variant n5: 3e-12 property variant n6: 3e+12 property variant n7: 0.1e9 + property variant n8: 1152921504606846976 property variant c1: "\b" // special characters property variant c2: "\f" diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 1c7a0876f6..850e1922a4 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -3053,6 +3053,7 @@ void tst_qqmllanguage::literals_data() QTest::newRow("fp3") << "n5" << QVariant(3e-12); QTest::newRow("fp4") << "n6" << QVariant(3e+12); QTest::newRow("fp5") << "n7" << QVariant(0.1e9); + QTest::newRow("large-int") << "n8" << QVariant((double) 1152921504606846976); QTest::newRow("special1") << "c1" << QVariant(QString("\b")); QTest::newRow("special2") << "c2" << QVariant(QString("\f")); |