diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-06-22 09:01:14 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-06-22 20:48:56 +0200 |
| commit | 2b9aa54610ce28b634d8e3008c624da6edf46330 (patch) | |
| tree | 0699e9aba9d464222e68ab576728fd068fb62dd4 /src/qmlcompiler/qqmljsfunctioninitializer.cpp | |
| parent | 031da6519072529481b045e67d143bd55a120aef (diff) | |
qmllint: Complain if function without return type returns something
Change-Id: I3058ebe82d84d6e6cd62f38a01dc61e9c3f46787
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsfunctioninitializer.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsfunctioninitializer.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsfunctioninitializer.cpp b/src/qmlcompiler/qqmljsfunctioninitializer.cpp index 3001af1152..9fb83014fe 100644 --- a/src/qmlcompiler/qqmljsfunctioninitializer.cpp +++ b/src/qmlcompiler/qqmljsfunctioninitializer.cpp @@ -59,6 +59,7 @@ void QQmlJSFunctionInitializer::populateSignature( error->type = QtWarningMsg; error->loc = ast->firstSourceLocation(); error->message = message; + function->isFullyTyped = false; }; if (!m_typeResolver->canCallJSFunctions()) { @@ -71,6 +72,11 @@ void QQmlJSFunctionInitializer::populateSignature( if (ast->formals) arguments = ast->formals->formals(); + // If the function has no arguments and no return type annotation we assume it's untyped. + // You can annotate it to return void to make it typed. + // Otherwise we first assume it's typed and reset the flag if we detect a problem. + function->isFullyTyped = !arguments.isEmpty() || ast->typeAnnotation; + if (function->argumentTypes.isEmpty()) { for (const QQmlJS::AST::BoundName &argument : std::as_const(arguments)) { if (argument.typeAnnotation) { |
