diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-10 22:55:55 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-11 07:17:29 +0000 |
commit | fd183d3db9d1eba4f7dd3e978192a247bf7dba85 (patch) | |
tree | c8359248c07cb4467e4c8b844a07a0d4ba8abaab /src/qml/compiler/qv4compilerscanfunctions.cpp | |
parent | e203a868470ab2e435111127f00530f4d8cc581d (diff) |
Give for loops a proper block scope for it's lexically declared vars
Change-Id: I71c40d1d061ac3c1c623dbbf8f7967c9ec35c082
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp')
-rw-r--r-- | src/qml/compiler/qv4compilerscanfunctions.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 31663e2162..c2256537c4 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -320,6 +320,8 @@ bool ScanFunctions::visit(DoWhileStatement *ast) { } bool ScanFunctions::visit(ForStatement *ast) { + enterEnvironment(ast, ContextType::Block); + _context->name = QLatin1String("For"); Node::accept(ast->initialiser, this); Node::accept(ast->declarations, this); Node::accept(ast->condition, this); @@ -331,6 +333,11 @@ bool ScanFunctions::visit(ForStatement *ast) { return false; } +void ScanFunctions::endVisit(ForStatement *) +{ + leaveEnvironment(); +} + bool ScanFunctions::visit(ForEachStatement *ast) { enterEnvironment(ast, ContextType::Block); _context->name = QLatin1String("Foreach"); |