diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2025-04-08 16:32:55 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2025-04-10 13:35:00 +0200 |
| commit | 3cb8e9b6056d66b409527617d87ae0c12135f6c5 (patch) | |
| tree | 0e6be24f9154d552e7c45bb03e385f7ac34660e3 /src/qmlcompiler/qqmljslogger.cpp | |
| parent | 5ff76ab872de6bae9766d52f4f794256ae9eeebf (diff) | |
qmllint: Warn about redundant optional chaining
Using an optional lookup '?.' on a base type that cannot be null or
undefined or when looking up an enum value is pointless. We generate a
normal lookup for this in the compiler, but the bytecode keeps these
redundant instructions in.
Task-number: QTBUG-135649
Change-Id: I95d8b4ed22afa1bdc46a3f8b3d60a499d43931ac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljslogger.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljslogger.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/qmlcompiler/qqmljslogger.cpp b/src/qmlcompiler/qqmljslogger.cpp index de666e25f3..7b79f50789 100644 --- a/src/qmlcompiler/qqmljslogger.cpp +++ b/src/qmlcompiler/qqmljslogger.cpp @@ -106,7 +106,10 @@ using namespace Qt::StringLiterals; "Warn about using missing enum values.", QtWarningMsg, false, false) \ X(qmlAssignmentInCondition, "assignment-in-condition", "AssignmentInCondition", \ "Warn about using assignment in conditions.", QtWarningMsg, false, false) \ - X(qmlEval, "eval", "Eval", "Warn about uses of eval()", QtWarningMsg, false, false) + X(qmlEval, "eval", "Eval", "Warn about uses of eval()", QtWarningMsg, false, false) \ + X(qmlRedundantOptionalChaining, "redundant-optional-chaining", "RedundantOptionalChaining", \ + "Warn about optional chaining on non-voidable and non-nullable base", QtWarningMsg, false, \ + false) #define X(category, name, setting, description, level, ignored, isDefault) \ const QQmlSA::LoggerWarningId category{ name }; |
