diff --git a/src/qmlcompiler/qqmljsfunctioninitializer.cpp b/src/qmlcompiler/qqmljsfunctioninitializer.cpp index 0139071cc0..8cd3bb3536 100644 --- a/src/qmlcompiler/qqmljsfunctioninitializer.cpp +++ b/src/qmlcompiler/qqmljsfunctioninitializer.cpp @@ -94,10 +94,12 @@ void QQmlJSFunctionInitializer::populateSignature( if (const auto type = m_typeResolver->typeFromAST(argument.typeAnnotation->type)) { function->argumentTypes.append(type); } else { + function->argumentTypes.append(m_typeResolver->varType()); signatureError(u"Cannot resolve the argument type %1."_qs .arg(argument.typeAnnotation->type->toString())); } } else { + function->argumentTypes.append(m_typeResolver->varType()); signatureError(u"Functions without type annotations won't be compiled"_qs); } } diff --git a/tests/auto/qml/qmllint/data/unknownTypeInRegister.qml b/tests/auto/qml/qmllint/data/unknownTypeInRegister.qml new file mode 100644 index 0000000000..72902d292b --- /dev/null +++ b/tests/auto/qml/qmllint/data/unknownTypeInRegister.qml @@ -0,0 +1,7 @@ +import QtQuick + +ListModel { + function foo(index) { + move(index, 1, 1); + } +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 5da838c299..b8fcdc49f3 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -90,6 +90,7 @@ private Q_SLOTS: void absolutePath(); void multiGrouped(); void javascriptVariableArgs(); + void unknownTypeInRegister(); private: enum DefaultIncludeOption { NoDefaultIncludes, UseDefaultIncludes }; @@ -1266,5 +1267,12 @@ void TestQmllint::javascriptVariableArgs() .contains(QStringLiteral("Function expects 0 arguments, but 2 were provided"))); } +void TestQmllint::unknownTypeInRegister() +{ + QVERIFY(runQmllint("unknownTypeInRegister.qml", false, { "--compiler", "warning" }) + .contains(QStringLiteral( + "Functions without type annotations won't be compiled"))); +} + QTEST_MAIN(TestQmllint) #include "tst_qmllint.moc"