qqmljstypepropagator: Use variant type for arguments of unknown type
Previously those function arguments would result in an invalid type being used which lead to crashes when invoking methods using those arguments. Pick-to: 6.3 Fixes: QTBUG-99027 Change-Id: I27e643f2512e1542d766b5fe98adfee043245c6f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
9f8b118bd1
commit
e83fd85cce
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import QtQuick
|
||||
|
||||
ListModel {
|
||||
function foo(index) {
|
||||
move(index, 1, 1);
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue