Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.1, 6.2
-
None
Description
There is an ambiguity with functions and UIObjects, for this reason the normal FunctionDeclaration was split in FunctionDeclaration_Default (with anonymous function) and FunctionDeclaration, that then continues in the HoistableStatemen and HoistableStatement_Default rules.
As consequence of that parsing of an anonymous function (or a function containing it) fails with parseStatement, parseExpression, parseScript.
The parsing in the UiBinding works though, but for example requires a space after the function keyword (and the AST token contains the space!).
I am not yet sure how the fix this, it crops up when I reformat the expression in the Dom and reparse just the modified expression.
For example tests/auto/qml/qmlformat/data/Example1.qml, but
Item { a: function (){ return 42; }() }
is a more compact example. With the space the parser can parse it (function() fails), but the DOM fails then the subsequent parse of the ScriptExpression without the context,
Currently I detect the failure and keep the old AST printing a warning, but a proper fix should be done.
By the way a js resource with
function foo(){ return function (){ return 420; }(); }
works
Attachments
Issue Links
- is required for
-
QTBUG-89391 Make DomModel usable by QML Design Studio
- Blocked