aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-05-10 23:29:23 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-11 07:17:33 +0000
commitfb04917e8eb1f7cc5832b2f13ab1d208b0e1014f (patch)
tree9018734b467c7b049180b104e84fa586f9d1912f
parentfd183d3db9d1eba4f7dd3e978192a247bf7dba85 (diff)
Give case blocks a proper scope
Change-Id: Id307c0426e1c9326ac085cebda71934cb5e612e0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/compiler/qv4codegen.cpp2
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp12
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions_p.h3
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations6
4 files changed, 17 insertions, 6 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 687731c32b..9c63360107 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2827,6 +2827,8 @@ bool Codegen::visit(SwitchStatement *ast)
RegisterScope scope(this);
if (ast->block) {
+ ControlFlowBlock controlFlow(this, ast->block);
+
BytecodeGenerator::Label switchEnd = bytecodeGenerator->newLabel();
Reference lhs = expression(ast->expression);
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index c2256537c4..372e240700 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -375,6 +375,18 @@ void ScanFunctions::endVisit(Block *)
leaveEnvironment();
}
+bool ScanFunctions::visit(CaseBlock *ast)
+{
+ enterEnvironment(ast, ContextType::Block);
+ _context->name = QLatin1String("CaseBlock");
+ return true;
+}
+
+void ScanFunctions::endVisit(CaseBlock *)
+{
+ leaveEnvironment();
+}
+
bool ScanFunctions::visit(Catch *ast)
{
TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, _context->isStrict ? false : _allowFuncDecls);
diff --git a/src/qml/compiler/qv4compilerscanfunctions_p.h b/src/qml/compiler/qv4compilerscanfunctions_p.h
index b9b41781c4..cb3866c596 100644
--- a/src/qml/compiler/qv4compilerscanfunctions_p.h
+++ b/src/qml/compiler/qv4compilerscanfunctions_p.h
@@ -134,6 +134,9 @@ protected:
bool visit(AST::Block *ast) override;
void endVisit(AST::Block *ast) override;
+ bool visit(AST::CaseBlock *ast) override;
+ void endVisit(AST::CaseBlock *ast) override;
+
bool visit(AST::Catch *ast) override;
void endVisit(AST::Catch *ast) override;
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index bcf845c8a8..bb442e0125 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -4897,8 +4897,6 @@ language/function-code/each-param-has-own-non-shared-eval-scope.js sloppyFails
language/function-code/each-param-has-own-scope.js sloppyFails
language/function-code/eval-param-env-with-computed-key.js sloppyFails
language/function-code/eval-param-env-with-prop-initializer.js sloppyFails
-language/function-code/switch-case-decl-strict.js strictFails
-language/function-code/switch-dflt-decl-strict.js strictFails
language/global-code/decl-lex-deletion.js sloppyFails
language/global-code/decl-lex-restricted-global.js fails
language/global-code/decl-lex.js fails
@@ -4914,8 +4912,6 @@ language/global-code/script-decl-lex.js fails
language/global-code/script-decl-var-collision.js fails
language/global-code/script-decl-var-err.js fails
language/global-code/script-decl-var.js fails
-language/global-code/switch-case-decl-strict.js strictFails
-language/global-code/switch-dflt-decl-strict.js strictFails
language/identifiers/other_id_continue.js fails
language/identifiers/other_id_start-escaped.js fails
language/identifiers/other_id_start.js fails
@@ -6631,8 +6627,6 @@ language/statements/let/syntax/let-iteration-variable-is-freshly-allocated-for-e
language/statements/let/syntax/let-iteration-variable-is-freshly-allocated-for-each-iteration-single-let-binding.js fails
language/statements/let/syntax/let.js fails
language/statements/return/tco.js strictFails
-language/statements/switch/scope-lex-close-case.js fails
-language/statements/switch/scope-lex-close-dflt.js fails
language/statements/switch/scope-lex-open-case.js fails
language/statements/switch/scope-lex-open-dflt.js fails
language/statements/switch/tco-case-body-dflt.js strictFails