summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-30 21:04:51 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-03 08:09:09 +0000
commitdcbdb306f4442199384a71d532a3610a84d13fd5 (patch)
treee51520aafbc9dd12cd8d0013070d67fcc32fe13a /src/qml/compiler/qv4codegen.cpp
parent6d8dbba4624c8a453ba13ff009f011f2946422bb (diff)
downloadqtdeclarative-dcbdb306f4442199384a71d532a3610a84d13fd5.tar.gz
Fix naming of classes in class expressions
As with function expressions, class expressions also get an implicitly defined name if they are directly assigned to a named variable. Change-Id: I5fda9d74c1c299107f15b82245333b54ca6d8917 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 36f959b301..cb9049c73d 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -914,9 +914,11 @@ bool Codegen::visit(ClassExpression *ast)
bytecodeGenerator->addInstruction(createClass);
- Reference ctor = referenceForName(ast->name.toString(), true);
- ctor.isReferenceToConst = false; // this is the definition
- (void) ctor.storeRetainAccumulator();
+ if (!ast->name.isEmpty()) {
+ Reference ctor = referenceForName(ast->name.toString(), true);
+ ctor.isReferenceToConst = false; // this is the definition
+ (void) ctor.storeRetainAccumulator();
+ }
_expr.setResult(Reference::fromAccumulator(this));
return false;