diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2025-12-11 15:55:26 +0100 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2025-12-18 17:29:47 +0100 |
| commit | 0953b874419781466f7393845c7f00bccfd40d65 (patch) | |
| tree | a3077356731d63c224c4dbeb4126db3ad590f9bd /src | |
| parent | 2353650311f0454c6ecbd31c744ca6e788ef6d6f (diff) | |
qqmldomastcreator: remove Q_UNREACHABLE that gets hit
It seems that Q_UNREACHABLE triggers UB at runtime when hit in a release
build, so remove it and log an error instead. Ignore the invalid part.
Pick-to: 6.11 6.10 6.8
Fixes: QTBUG-142711
Change-Id: I445e46a6964f072a939cd6666c15c8d1ff5a0966
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmldom/qqmldomastcreator.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qmldom/qqmldomastcreator.cpp b/src/qmldom/qqmldomastcreator.cpp index bfa2c373f1..babc7a8c08 100644 --- a/src/qmldom/qqmldomastcreator.cpp +++ b/src/qmldom/qqmldomastcreator.cpp @@ -864,9 +864,10 @@ bool QQmlDomAstCreatorBase::visit(AST::FunctionDeclaration *fDef) bool QQmlDomAstCreatorBase::visit(AST::UiSourceElement *el) { - if (!cast<FunctionDeclaration *>(el->sourceElement)) { - qCWarning(creatorLog) << "unhandled source el:" << static_cast<AST::Node *>(el); - Q_UNREACHABLE(); + if (AST::cast<VariableStatement *>(el->sourceElement)) { + qmlFile.addError(astParseErrors().warning( + "JavaScript declarations are not allowed in QML elements"_L1)); + return false; } return true; } @@ -938,6 +939,8 @@ void QQmlDomAstCreatorBase::endVisit(AST::FunctionDeclaration *fDef) void QQmlDomAstCreatorBase::endVisit(AST::UiSourceElement *el) { + if (AST::cast<VariableStatement *>(el->sourceElement)) + return; MethodInfo &m = std::get<MethodInfo>(currentNode().value); loadAnnotations(el); QmlObject &obj = current<QmlObject>(); |
