diff options
author | Sami Shalayel <[email protected]> | 2025-03-31 16:27:06 +0200 |
---|---|---|
committer | Sami Shalayel <[email protected]> | 2025-04-24 14:45:48 +0200 |
commit | 9b2cff650a5452d38b45c6e40f8b7eea7a048d77 (patch) | |
tree | f25bd880637696198b91026becdb78592d226a5c /src/qmlcompiler/qqmljsloggingutils.h | |
parent | 9a5e2a72a1b696dbd935c6dd656c1520dc14952a (diff) |
qmllint: Implement WarnFunctionUsedBeforeDeclaration
Warn about functions used before their declaration. Its not technically
an error like the "var used before declaration" because functions are
"hoisted up" and therefore available even before their declaration, so
create a new warning category for it instead of reusing the "var used
before declaration" category. Disable the warning by default: Qt Creator
used to have it as default, while other tools like eslint don't.
For the same reason, don't warn about functions used before declaration
during codegen, and add a method to warn about it in
CodeGenWarningInterface. The code for "var used before declaration"
can be reused by function declarations by adding a sourcelocation for
function declarations in the "addLocalVar"-call, so make sure to
differentiate between functions and vars by adding an extra member to
Context::ResolvedName.
Task-number: QTBUG-129307
Change-Id: I83a4f8cd00c120db23a0cec3365a00ed44de2836
Reviewed-by: Olivier De Cannière <[email protected]>
Diffstat (limited to 'src/qmlcompiler/qqmljsloggingutils.h')
-rw-r--r-- | src/qmlcompiler/qqmljsloggingutils.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsloggingutils.h b/src/qmlcompiler/qqmljsloggingutils.h index 078b7d1a45..56d4ac49b5 100644 --- a/src/qmlcompiler/qqmljsloggingutils.h +++ b/src/qmlcompiler/qqmljsloggingutils.h @@ -70,6 +70,7 @@ extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlCompiler; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlAttachedPropertyReuse; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlPlugin; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlVarUsedBeforeDeclaration; +extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlFunctionUsedBeforeDeclaration; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlInvalidLintDirective; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlUseProperFunction; extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlAccessSingleton; |