From 046d1c5db44f409c67244bd70b13077cc03219b2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 22 Jun 2018 00:09:31 +0200 Subject: throw a type error when trying to write to a const variable This makes them really const. The codegen needs some smaller changes to ensure that writing to the variable when it's being defined is allowed. Change-Id: I781b4bc9c0e0397b9d00cad3daf758a062c17600 Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4compilerscanfunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 8b8c385b84..9be55c6ad0 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -230,7 +230,7 @@ bool ScanFunctions::visit(ClassExpression *ast) _context->isStrict = true; _context->hasNestedFunctions = true; if (!ast->name.isEmpty()) - _context->addLocalVar(ast->name.toString(), Context::VariableDeclaration, AST::VariableScope::Let); + _context->addLocalVar(ast->name.toString(), Context::VariableDefinition, AST::VariableScope::Const); return true; } @@ -248,7 +248,7 @@ bool ScanFunctions::visit(ClassDeclaration *ast) _context->isStrict = true; _context->hasNestedFunctions = true; if (!ast->name.isEmpty()) - _context->addLocalVar(ast->name.toString(), Context::VariableDeclaration, AST::VariableScope::Let); + _context->addLocalVar(ast->name.toString(), Context::VariableDefinition, AST::VariableScope::Const); return true; } -- cgit v1.2.3