diff options
-rw-r--r-- | src/qmlcompiler/qqmljstypepropagator.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/failures.qml | 3 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/initReadonly.qml | 1 |
3 files changed, 5 insertions, 1 deletions
diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp index e8f1844a2f..0c642c4c84 100644 --- a/src/qmlcompiler/qqmljstypepropagator.cpp +++ b/src/qmlcompiler/qqmljstypepropagator.cpp @@ -628,7 +628,7 @@ void QQmlJSTypePropagator::generate_StoreNameCommon(int nameIndex) return; } - if (!type.isWritable() && !m_function->qmlScope->hasOwnProperty(name)) { + if (!type.isWritable()) { setError(u"Can't assign to read-only property %1"_s.arg(name)); m_logger->log(u"Cannot assign to read-only property %1"_s.arg(name), qmlReadOnlyProperty, diff --git a/tests/auto/qml/qmlcppcodegen/data/failures.qml b/tests/auto/qml/qmlcppcodegen/data/failures.qml index 11d0389262..bd4f1677e6 100644 --- a/tests/auto/qml/qmlcppcodegen/data/failures.qml +++ b/tests/auto/qml/qmlcppcodegen/data/failures.qml @@ -107,4 +107,7 @@ QtObject { self.selfself.nastyBad = undefined; return 5; } + + readonly property int someNumber: 10 + function writeToReadonly() { someNumber = 20 } } diff --git a/tests/auto/qml/qmllint/data/initReadonly.qml b/tests/auto/qml/qmllint/data/initReadonly.qml index 5a3cafff23..a9a2a0016b 100644 --- a/tests/auto/qml/qmllint/data/initReadonly.qml +++ b/tests/auto/qml/qmllint/data/initReadonly.qml @@ -2,4 +2,5 @@ import QtQml QtObject { readonly property int i: 14 + readonly property int j: i + 20 } |