diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-04 10:12:18 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-21 13:30:31 +0000 |
commit | 9959e9c364ca20012e54371d6919e8f2a9c6012f (patch) | |
tree | 4fd9bdf0bb2d7fbc26ed46eeb3dd6d311435afe5 /src/qml/parser | |
parent | 491a2c2186f9caf01002a44aa04df894f3604b76 (diff) |
Correctly set the name of anonymous functions in most cases
If the anonymous function is bound to an identifier, set the
name to the identifier.
Change-Id: Idbb3170210e6f91cca3c9bd36b2b6ddcb3a50c7b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r-- | src/qml/parser/qqmljs.g | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index 5fd927a51b..cf9f1edd62 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -2944,6 +2944,9 @@ BindingProperty: BindingIdentifier InitializerOpt_In; case $rule_number: { AST::StringLiteralPropertyName *name = new (pool) AST::StringLiteralPropertyName(stringRef(1)); name->propertyNameToken = loc(1); + // if initializer is an anonymous function expression, we need to assign identifierref as it's name + if (auto *f = asAnonymousFunctionDefinition(sym(2).Expression)) + f->name = stringRef(1); sym(1).Node = new (pool) AST::PatternProperty(name, stringRef(1), sym(2).Expression); } break; ./ @@ -2969,6 +2972,9 @@ BindingElement: BindingIdentifier InitializerOpt_In; case $rule_number: { AST::PatternElement *node = new (pool) AST::PatternElement(stringRef(1), sym(2).Expression); node->identifierToken = loc(1); + // if initializer is an anonymous function expression, we need to assign identifierref as it's name + if (auto *f = asAnonymousFunctionDefinition(sym(2).Expression)) + f->name = stringRef(1); sym(1).Node = node; } break; ./ |