diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-06-12 15:55:36 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-08-30 15:20:01 +0000 |
commit | 10f0416e63da4e7798a39854738aff5106d40fb3 (patch) | |
tree | 3e0e3af5f3b8f0e2537a4ac5ed0586dc40e07772 /src | |
parent | 60b442389874932815e9246521911099a128310e (diff) |
qmllint: Detect unqualified id access in StoreNameSloppy
In QQmlJSTypePropagator::generate_StoreName, we would return early in a
few error cases (after calling setError). That is okay for the compiler,
which cares about setError, but qmllint is not interested in compiler
errors by default.
This would result in us not issuing warnings about unqualified id
accesses.
Fix this by also logging the errors via the logger.
Fixes: QTBUG-114467
Change-Id: I10ad10e5c93762b3d9d1fb50d3cabcff2c0b7a4f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 15082891f78d3e6df121fbaef7626be5250bd1e4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qmlcompiler/qqmljstypepropagator.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp index f02d1eb599..4b6dd1181c 100644 --- a/src/qmlcompiler/qqmljstypepropagator.cpp +++ b/src/qmlcompiler/qqmljstypepropagator.cpp @@ -594,11 +594,18 @@ void QQmlJSTypePropagator::generate_StoreNameSloppy(int nameIndex) const QQmlJSRegisterContent in = m_state.accumulatorIn(); if (!type.isValid()) { + handleUnqualifiedAccess(name, false); setError(u"Cannot find name "_s + name); return; } if (!type.isProperty()) { + QString message = type.isMethod() ? u"Cannot assign to method %1"_s + : u"Cannot assign to non-property %1"_s; + // The interpreter treats methods as read-only properties in its error messages + // and we lack a better fitting category. We might want to revisit this later. + m_logger->log(message.arg(name), qmlReadOnlyProperty, + getCurrentSourceLocation()); setError(u"Cannot assign to non-property "_s + name); return; } |