From b63393c7aac7c337672b87a914cb059f60091584 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sat, 28 Jan 2017 13:48:06 +0100 Subject: Codegen: Disallow const declaration without an initializer expression This seems to match up with the spec behavior. 13.3.1.1 (Static Semantics: Early Errors) says: It is a Syntax Error if Initializer is not present and IsConstantDeclaration of the LexicalDeclaration containing this production is true. In addition, we also allow "const" to be used in JS mode too. We don't yet fully support the semantics, but as it's there, why not let it work. [ChangeLog][QtQml] "const" variable declarations are now available in JS as well as QML mode. [ChangeLog][QtQml] "const" variable declarations now require an initializer, bringing them closer to the required spec behavior. Task-number: QTBUG-58493 Change-Id: Ife5d5979b3e7a5d7340bf04f43605f847ee25ee2 Reviewed-by: Simon Hausmann --- src/qml/parser/qqmljskeywords_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/parser') diff --git a/src/qml/parser/qqmljskeywords_p.h b/src/qml/parser/qqmljskeywords_p.h index 84ebe5f210..a31c188efc 100644 --- a/src/qml/parser/qqmljskeywords_p.h +++ b/src/qml/parser/qqmljskeywords_p.h @@ -278,7 +278,7 @@ static inline int classify5(const QChar *s, bool qmlMode) { if (s[2].unicode() == 'n') { if (s[3].unicode() == 's') { if (s[4].unicode() == 't') { - return qmlMode ? int(Lexer::T_CONST) : int(Lexer::T_RESERVED_WORD); + return int(Lexer::T_CONST); } } } -- cgit v1.2.3