haikuwebkit/LayoutTests/js/arrowfunction-syntax-errors...

152 lines
11 KiB
Plaintext
Raw Permalink Normal View History

Source/JavaScriptCore: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function. https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc. This patch implements the simplest cases of arrow function declaration: parameters () => 10 + 20 parameter x => x + 20 parameters (x, y) => x + y function with block x => { return x*10; } Not implemented: bind of the this, arguments, super and etc. exception in case of trying to use 'new' with arrow function Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * parser/ASTBuilder.h: (JSC::ASTBuilder::createFunctionExpr): (JSC::ASTBuilder::createArrowFunctionExpr): (JSC::ASTBuilder::createGetterOrSetterProperty): (JSC::ASTBuilder::createFuncDeclStatement): * parser/Lexer.cpp: (JSC::Lexer<T>::setTokenPosition): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::lastTokenLocation): (JSC::Lexer::setTerminator): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseSourceElements): (JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody): (JSC::Parser<LexerType>::parseSwitchClauses): (JSC::Parser<LexerType>::parseSwitchDefaultClause): (JSC::Parser<LexerType>::parseBlockStatement): (JSC::Parser<LexerType>::parseFunctionBody): (JSC::stringForFunctionMode): (JSC::Parser<LexerType>::parseFunctionParameters): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): (JSC::Parser<LexerType>::parseAssignmentExpression): (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parseGetterSetter): (JSC::Parser<LexerType>::parseArrowFunctionExpression): * parser/Parser.h: (JSC::Parser::locationBeforeLastToken): (JSC::Parser::isEndOfArrowFunction): (JSC::Parser::isArrowFunctionParamters): (JSC::Parser::setEndOfStatement): * parser/ParserFunctionInfo.h: * parser/ParserTokens.h: * parser/SourceCode.h: (JSC::SourceCode::subArrowExpression): * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::endFunctionToken): (JSC::SourceProviderCacheItem::SourceProviderCacheItem): * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createArrowFunctionExpr): (JSC::SyntaxChecker::setFunctionNameStart): LayoutTests: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added arrow function tests Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * js/arrowfunction-asparamter-1-expected.txt: Added. * js/arrowfunction-asparamter-1.html: Added. * js/arrowfunction-asparamter-2-expected.txt: Added. * js/arrowfunction-asparamter-2.html: Added. * js/arrowfunction-associativity-1-expected.txt: Added. * js/arrowfunction-associativity-1.html: Added. * js/arrowfunction-associativity-2-expected.txt: Added. * js/arrowfunction-associativity-2.html: Added. * js/arrowfunction-block-1-expected.txt: Added. * js/arrowfunction-block-1.html: Added. * js/arrowfunction-block-2-expected.txt: Added. * js/arrowfunction-block-2.html: Added. * js/arrowfunction-syntax-endings-expected.txt: Added. * js/arrowfunction-syntax-endings.html: Added. * js/arrowfunction-syntax-errors-expected.txt: Added. * js/arrowfunction-syntax-errors.html: Added. * js/arrowfunction-syntax-expected.txt: Added. * js/arrowfunction-syntax.html: Added. * js/script-tests/arrowfunction-asparamter-1.js: Added. * js/script-tests/arrowfunction-asparamter-2.js: Added. * js/script-tests/arrowfunction-associativity-1.js: Added. * js/script-tests/arrowfunction-associativity-2.js: Added. * js/script-tests/arrowfunction-block-1.js: Added. * js/script-tests/arrowfunction-block-2.js: Added. * js/script-tests/arrowfunction-syntax-endings.js: Added. * js/script-tests/arrowfunction-syntax-errors.js: Added. * js/script-tests/arrowfunction-syntax.js: Added. Canonical link: https://commits.webkit.org/164423@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-06-26 06:49:20 +00:00
Tests for ES6 arrow function syntax errors
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS =>{} threw exception SyntaxError: Unexpected token '=>'.
Source/JavaScriptCore: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function. https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc. This patch implements the simplest cases of arrow function declaration: parameters () => 10 + 20 parameter x => x + 20 parameters (x, y) => x + y function with block x => { return x*10; } Not implemented: bind of the this, arguments, super and etc. exception in case of trying to use 'new' with arrow function Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * parser/ASTBuilder.h: (JSC::ASTBuilder::createFunctionExpr): (JSC::ASTBuilder::createArrowFunctionExpr): (JSC::ASTBuilder::createGetterOrSetterProperty): (JSC::ASTBuilder::createFuncDeclStatement): * parser/Lexer.cpp: (JSC::Lexer<T>::setTokenPosition): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::lastTokenLocation): (JSC::Lexer::setTerminator): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseSourceElements): (JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody): (JSC::Parser<LexerType>::parseSwitchClauses): (JSC::Parser<LexerType>::parseSwitchDefaultClause): (JSC::Parser<LexerType>::parseBlockStatement): (JSC::Parser<LexerType>::parseFunctionBody): (JSC::stringForFunctionMode): (JSC::Parser<LexerType>::parseFunctionParameters): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): (JSC::Parser<LexerType>::parseAssignmentExpression): (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parseGetterSetter): (JSC::Parser<LexerType>::parseArrowFunctionExpression): * parser/Parser.h: (JSC::Parser::locationBeforeLastToken): (JSC::Parser::isEndOfArrowFunction): (JSC::Parser::isArrowFunctionParamters): (JSC::Parser::setEndOfStatement): * parser/ParserFunctionInfo.h: * parser/ParserTokens.h: * parser/SourceCode.h: (JSC::SourceCode::subArrowExpression): * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::endFunctionToken): (JSC::SourceProviderCacheItem::SourceProviderCacheItem): * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createArrowFunctionExpr): (JSC::SyntaxChecker::setFunctionNameStart): LayoutTests: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added arrow function tests Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * js/arrowfunction-asparamter-1-expected.txt: Added. * js/arrowfunction-asparamter-1.html: Added. * js/arrowfunction-asparamter-2-expected.txt: Added. * js/arrowfunction-asparamter-2.html: Added. * js/arrowfunction-associativity-1-expected.txt: Added. * js/arrowfunction-associativity-1.html: Added. * js/arrowfunction-associativity-2-expected.txt: Added. * js/arrowfunction-associativity-2.html: Added. * js/arrowfunction-block-1-expected.txt: Added. * js/arrowfunction-block-1.html: Added. * js/arrowfunction-block-2-expected.txt: Added. * js/arrowfunction-block-2.html: Added. * js/arrowfunction-syntax-endings-expected.txt: Added. * js/arrowfunction-syntax-endings.html: Added. * js/arrowfunction-syntax-errors-expected.txt: Added. * js/arrowfunction-syntax-errors.html: Added. * js/arrowfunction-syntax-expected.txt: Added. * js/arrowfunction-syntax.html: Added. * js/script-tests/arrowfunction-asparamter-1.js: Added. * js/script-tests/arrowfunction-asparamter-2.js: Added. * js/script-tests/arrowfunction-associativity-1.js: Added. * js/script-tests/arrowfunction-associativity-2.js: Added. * js/script-tests/arrowfunction-block-1.js: Added. * js/script-tests/arrowfunction-block-2.js: Added. * js/script-tests/arrowfunction-syntax-endings.js: Added. * js/script-tests/arrowfunction-syntax-errors.js: Added. * js/script-tests/arrowfunction-syntax.js: Added. Canonical link: https://commits.webkit.org/164423@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-06-26 06:49:20 +00:00
PASS x=> threw exception SyntaxError: Unexpected end of script.
PASS x=>* threw exception SyntaxError: Unexpected token '*'.
Arrow functions with concise bodies cannot return regular expressions https://bugs.webkit.org/show_bug.cgi?id=163162 Reviewed by Filip Pizlo. JSTests: * ChakraCore/test/Operators/instanceof.baseline-jsc: * ChakraCore/test/Regex/nul_character.baseline-jsc: * ChakraCore/test/es5/Lex_u3.baseline-jsc: * stress/parse-regexp-as-token.js: Added. (shouldBe): Source/JavaScriptCore: When we encounter the RegExp in the parser, we first scan it as / or /=. And if / or /= is parsed under the primary expression context, we rescan it as RegExp. However, we did not update the token record information. So the token record still says "I'm / or /=". When we parse the string "() => /hello/", the last token becomes "/", which is the first character of the RegExp, instead of "/hello/". Since the arrow function parsing utilizes the end offset of the last token, we accidentally recognize the range of the above arrow function as "() => /". In this patch, we update the token when rescanning under the RegExp context. This logic is similar to parsing Tail Template Literal token. We also refine the error message for regular expression literals. And since the REGEXP token is now introduced, the other error messages using that token are improved too. Currently, unterminated error messages can be seen in Parser.cpp. However, these messages cannot be shown to users if the lexer has m_error. So these code is meaningless. I'll move these tokenizing errors to the lexer in the subsequent patch[1]. [1]: https://bugs.webkit.org/show_bug.cgi?id=163928 * parser/Lexer.cpp: (JSC::Lexer<T>::fillTokenInfo): (JSC::Lexer<T>::lex): (JSC::Lexer<T>::scanRegExp): (JSC::Lexer<T>::scanTrailingTemplateString): (JSC::Lexer<T>::skipRegExp): Deleted. * parser/Lexer.h: (JSC::Lexer::getToken): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseAssignmentExpression): * parser/Parser.h: (JSC::Parser::getToken): * parser/ParserTokens.h: LayoutTests: * fast/regex/dom/non-pattern-characters-expected.txt: * js/arrowfunction-syntax-errors-expected.txt: * js/regexp-compile-crash-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A4_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A4_T4-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.2_T2-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.3_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.3_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.5_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.5_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.2_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.3_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.3_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.5_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.5_T3-expected.txt: Canonical link: https://commits.webkit.org/181658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207798 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-25 02:35:59 +00:00
PASS x=>/ threw exception SyntaxError: Unterminated regular expression literal '/'.
Source/JavaScriptCore: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function. https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc. This patch implements the simplest cases of arrow function declaration: parameters () => 10 + 20 parameter x => x + 20 parameters (x, y) => x + y function with block x => { return x*10; } Not implemented: bind of the this, arguments, super and etc. exception in case of trying to use 'new' with arrow function Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * parser/ASTBuilder.h: (JSC::ASTBuilder::createFunctionExpr): (JSC::ASTBuilder::createArrowFunctionExpr): (JSC::ASTBuilder::createGetterOrSetterProperty): (JSC::ASTBuilder::createFuncDeclStatement): * parser/Lexer.cpp: (JSC::Lexer<T>::setTokenPosition): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::lastTokenLocation): (JSC::Lexer::setTerminator): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseSourceElements): (JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody): (JSC::Parser<LexerType>::parseSwitchClauses): (JSC::Parser<LexerType>::parseSwitchDefaultClause): (JSC::Parser<LexerType>::parseBlockStatement): (JSC::Parser<LexerType>::parseFunctionBody): (JSC::stringForFunctionMode): (JSC::Parser<LexerType>::parseFunctionParameters): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): (JSC::Parser<LexerType>::parseAssignmentExpression): (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parseGetterSetter): (JSC::Parser<LexerType>::parseArrowFunctionExpression): * parser/Parser.h: (JSC::Parser::locationBeforeLastToken): (JSC::Parser::isEndOfArrowFunction): (JSC::Parser::isArrowFunctionParamters): (JSC::Parser::setEndOfStatement): * parser/ParserFunctionInfo.h: * parser/ParserTokens.h: * parser/SourceCode.h: (JSC::SourceCode::subArrowExpression): * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::endFunctionToken): (JSC::SourceProviderCacheItem::SourceProviderCacheItem): * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createArrowFunctionExpr): (JSC::SyntaxChecker::setFunctionNameStart): LayoutTests: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added arrow function tests Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * js/arrowfunction-asparamter-1-expected.txt: Added. * js/arrowfunction-asparamter-1.html: Added. * js/arrowfunction-asparamter-2-expected.txt: Added. * js/arrowfunction-asparamter-2.html: Added. * js/arrowfunction-associativity-1-expected.txt: Added. * js/arrowfunction-associativity-1.html: Added. * js/arrowfunction-associativity-2-expected.txt: Added. * js/arrowfunction-associativity-2.html: Added. * js/arrowfunction-block-1-expected.txt: Added. * js/arrowfunction-block-1.html: Added. * js/arrowfunction-block-2-expected.txt: Added. * js/arrowfunction-block-2.html: Added. * js/arrowfunction-syntax-endings-expected.txt: Added. * js/arrowfunction-syntax-endings.html: Added. * js/arrowfunction-syntax-errors-expected.txt: Added. * js/arrowfunction-syntax-errors.html: Added. * js/arrowfunction-syntax-expected.txt: Added. * js/arrowfunction-syntax.html: Added. * js/script-tests/arrowfunction-asparamter-1.js: Added. * js/script-tests/arrowfunction-asparamter-2.js: Added. * js/script-tests/arrowfunction-associativity-1.js: Added. * js/script-tests/arrowfunction-associativity-2.js: Added. * js/script-tests/arrowfunction-block-1.js: Added. * js/script-tests/arrowfunction-block-2.js: Added. * js/script-tests/arrowfunction-syntax-endings.js: Added. * js/script-tests/arrowfunction-syntax-errors.js: Added. * js/script-tests/arrowfunction-syntax.js: Added. Canonical link: https://commits.webkit.org/164423@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-06-26 06:49:20 +00:00
PASS x=>% threw exception SyntaxError: Unexpected token '%'.
PASS x=>+ threw exception SyntaxError: Unexpected end of script.
PASS x=>- threw exception SyntaxError: Unexpected end of script.
PASS x=><< threw exception SyntaxError: Unexpected token '<<'.
PASS x=>>> threw exception SyntaxError: Unexpected token '>>'.
PASS x=>>>> threw exception SyntaxError: Unexpected token '>>>'.
PASS x=>< threw exception SyntaxError: Unexpected token '<'.
PASS x=>> threw exception SyntaxError: Unexpected token '>'.
PASS x=><= threw exception SyntaxError: Unexpected token '<='.
PASS x=>>= threw exception SyntaxError: Unexpected token '>='.
PASS x=>instanceof threw exception SyntaxError: Unexpected keyword 'instanceof'.
PASS x=>in threw exception SyntaxError: Unexpected keyword 'in'.
PASS x=>== threw exception SyntaxError: Unexpected token '=='.
PASS x=>!= threw exception SyntaxError: Unexpected token '!='.
PASS x=>=== threw exception SyntaxError: Unexpected token '==='.
PASS x=>!== threw exception SyntaxError: Unexpected token '!=='.
PASS x=>& threw exception SyntaxError: Unexpected token '&'.
PASS x=>^ threw exception SyntaxError: Unexpected token '^'.
PASS x=>| threw exception SyntaxError: Unexpected token '|'.
PASS x=>&& threw exception SyntaxError: Unexpected token '&&'.
PASS x=>|| threw exception SyntaxError: Unexpected token '||'.
PASS x=>; threw exception SyntaxError: Unexpected token ';'.
PASS x=>, threw exception SyntaxError: Unexpected token ','.
PASS x=>{ threw exception SyntaxError: Unexpected end of script.
PASS x=>{* threw exception SyntaxError: Unexpected token '*'.
Arrow functions with concise bodies cannot return regular expressions https://bugs.webkit.org/show_bug.cgi?id=163162 Reviewed by Filip Pizlo. JSTests: * ChakraCore/test/Operators/instanceof.baseline-jsc: * ChakraCore/test/Regex/nul_character.baseline-jsc: * ChakraCore/test/es5/Lex_u3.baseline-jsc: * stress/parse-regexp-as-token.js: Added. (shouldBe): Source/JavaScriptCore: When we encounter the RegExp in the parser, we first scan it as / or /=. And if / or /= is parsed under the primary expression context, we rescan it as RegExp. However, we did not update the token record information. So the token record still says "I'm / or /=". When we parse the string "() => /hello/", the last token becomes "/", which is the first character of the RegExp, instead of "/hello/". Since the arrow function parsing utilizes the end offset of the last token, we accidentally recognize the range of the above arrow function as "() => /". In this patch, we update the token when rescanning under the RegExp context. This logic is similar to parsing Tail Template Literal token. We also refine the error message for regular expression literals. And since the REGEXP token is now introduced, the other error messages using that token are improved too. Currently, unterminated error messages can be seen in Parser.cpp. However, these messages cannot be shown to users if the lexer has m_error. So these code is meaningless. I'll move these tokenizing errors to the lexer in the subsequent patch[1]. [1]: https://bugs.webkit.org/show_bug.cgi?id=163928 * parser/Lexer.cpp: (JSC::Lexer<T>::fillTokenInfo): (JSC::Lexer<T>::lex): (JSC::Lexer<T>::scanRegExp): (JSC::Lexer<T>::scanTrailingTemplateString): (JSC::Lexer<T>::skipRegExp): Deleted. * parser/Lexer.h: (JSC::Lexer::getToken): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseAssignmentExpression): * parser/Parser.h: (JSC::Parser::getToken): * parser/ParserTokens.h: LayoutTests: * fast/regex/dom/non-pattern-characters-expected.txt: * js/arrowfunction-syntax-errors-expected.txt: * js/regexp-compile-crash-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A4_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A4_T4-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.2_T2-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.3_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.3_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.5_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.5_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.2_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.3_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.3_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.5_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.5_T3-expected.txt: Canonical link: https://commits.webkit.org/181658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207798 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-25 02:35:59 +00:00
PASS x=>{/ threw exception SyntaxError: Unterminated regular expression literal '/'.
Source/JavaScriptCore: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function. https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc. This patch implements the simplest cases of arrow function declaration: parameters () => 10 + 20 parameter x => x + 20 parameters (x, y) => x + y function with block x => { return x*10; } Not implemented: bind of the this, arguments, super and etc. exception in case of trying to use 'new' with arrow function Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * parser/ASTBuilder.h: (JSC::ASTBuilder::createFunctionExpr): (JSC::ASTBuilder::createArrowFunctionExpr): (JSC::ASTBuilder::createGetterOrSetterProperty): (JSC::ASTBuilder::createFuncDeclStatement): * parser/Lexer.cpp: (JSC::Lexer<T>::setTokenPosition): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::lastTokenLocation): (JSC::Lexer::setTerminator): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseSourceElements): (JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody): (JSC::Parser<LexerType>::parseSwitchClauses): (JSC::Parser<LexerType>::parseSwitchDefaultClause): (JSC::Parser<LexerType>::parseBlockStatement): (JSC::Parser<LexerType>::parseFunctionBody): (JSC::stringForFunctionMode): (JSC::Parser<LexerType>::parseFunctionParameters): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): (JSC::Parser<LexerType>::parseAssignmentExpression): (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parseGetterSetter): (JSC::Parser<LexerType>::parseArrowFunctionExpression): * parser/Parser.h: (JSC::Parser::locationBeforeLastToken): (JSC::Parser::isEndOfArrowFunction): (JSC::Parser::isArrowFunctionParamters): (JSC::Parser::setEndOfStatement): * parser/ParserFunctionInfo.h: * parser/ParserTokens.h: * parser/SourceCode.h: (JSC::SourceCode::subArrowExpression): * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::endFunctionToken): (JSC::SourceProviderCacheItem::SourceProviderCacheItem): * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createArrowFunctionExpr): (JSC::SyntaxChecker::setFunctionNameStart): LayoutTests: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added arrow function tests Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * js/arrowfunction-asparamter-1-expected.txt: Added. * js/arrowfunction-asparamter-1.html: Added. * js/arrowfunction-asparamter-2-expected.txt: Added. * js/arrowfunction-asparamter-2.html: Added. * js/arrowfunction-associativity-1-expected.txt: Added. * js/arrowfunction-associativity-1.html: Added. * js/arrowfunction-associativity-2-expected.txt: Added. * js/arrowfunction-associativity-2.html: Added. * js/arrowfunction-block-1-expected.txt: Added. * js/arrowfunction-block-1.html: Added. * js/arrowfunction-block-2-expected.txt: Added. * js/arrowfunction-block-2.html: Added. * js/arrowfunction-syntax-endings-expected.txt: Added. * js/arrowfunction-syntax-endings.html: Added. * js/arrowfunction-syntax-errors-expected.txt: Added. * js/arrowfunction-syntax-errors.html: Added. * js/arrowfunction-syntax-expected.txt: Added. * js/arrowfunction-syntax.html: Added. * js/script-tests/arrowfunction-asparamter-1.js: Added. * js/script-tests/arrowfunction-asparamter-2.js: Added. * js/script-tests/arrowfunction-associativity-1.js: Added. * js/script-tests/arrowfunction-associativity-2.js: Added. * js/script-tests/arrowfunction-block-1.js: Added. * js/script-tests/arrowfunction-block-2.js: Added. * js/script-tests/arrowfunction-syntax-endings.js: Added. * js/script-tests/arrowfunction-syntax-errors.js: Added. * js/script-tests/arrowfunction-syntax.js: Added. Canonical link: https://commits.webkit.org/164423@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-06-26 06:49:20 +00:00
PASS x=>{% threw exception SyntaxError: Unexpected token '%'.
PASS x=>{+ threw exception SyntaxError: Unexpected end of script.
PASS x=>{- threw exception SyntaxError: Unexpected end of script.
PASS x=>{<< threw exception SyntaxError: Unexpected token '<<'.
PASS x=>{>> threw exception SyntaxError: Unexpected token '>>'.
PASS x=>{>>> threw exception SyntaxError: Unexpected token '>>>'.
PASS x=>{< threw exception SyntaxError: Unexpected token '<'.
PASS x=>{> threw exception SyntaxError: Unexpected token '>'.
PASS x=>{<= threw exception SyntaxError: Unexpected token '<='.
PASS x=>{>= threw exception SyntaxError: Unexpected token '>='.
PASS x=>{instanceof threw exception SyntaxError: Unexpected keyword 'instanceof'.
PASS x=>{in threw exception SyntaxError: Unexpected keyword 'in'.
PASS x=>{== threw exception SyntaxError: Unexpected token '=='.
PASS x=>{!= threw exception SyntaxError: Unexpected token '!='.
PASS x=>{=== threw exception SyntaxError: Unexpected token '==='.
PASS x=>{!== threw exception SyntaxError: Unexpected token '!=='.
PASS x=>{& threw exception SyntaxError: Unexpected token '&'.
PASS x=>{^ threw exception SyntaxError: Unexpected token '^'.
PASS x=>{| threw exception SyntaxError: Unexpected token '|'.
PASS x=>{&& threw exception SyntaxError: Unexpected token '&&'.
PASS x=>{|| threw exception SyntaxError: Unexpected token '||'.
PASS x=>{; threw exception SyntaxError: Unexpected end of script.
PASS x=>{, threw exception SyntaxError: Unexpected token ','.
PASS x=>} threw exception SyntaxError: Unexpected token '}'.
PASS var y = x=> threw exception SyntaxError: Unexpected end of script.
PASS var y = x=>* threw exception SyntaxError: Unexpected token '*'.
Arrow functions with concise bodies cannot return regular expressions https://bugs.webkit.org/show_bug.cgi?id=163162 Reviewed by Filip Pizlo. JSTests: * ChakraCore/test/Operators/instanceof.baseline-jsc: * ChakraCore/test/Regex/nul_character.baseline-jsc: * ChakraCore/test/es5/Lex_u3.baseline-jsc: * stress/parse-regexp-as-token.js: Added. (shouldBe): Source/JavaScriptCore: When we encounter the RegExp in the parser, we first scan it as / or /=. And if / or /= is parsed under the primary expression context, we rescan it as RegExp. However, we did not update the token record information. So the token record still says "I'm / or /=". When we parse the string "() => /hello/", the last token becomes "/", which is the first character of the RegExp, instead of "/hello/". Since the arrow function parsing utilizes the end offset of the last token, we accidentally recognize the range of the above arrow function as "() => /". In this patch, we update the token when rescanning under the RegExp context. This logic is similar to parsing Tail Template Literal token. We also refine the error message for regular expression literals. And since the REGEXP token is now introduced, the other error messages using that token are improved too. Currently, unterminated error messages can be seen in Parser.cpp. However, these messages cannot be shown to users if the lexer has m_error. So these code is meaningless. I'll move these tokenizing errors to the lexer in the subsequent patch[1]. [1]: https://bugs.webkit.org/show_bug.cgi?id=163928 * parser/Lexer.cpp: (JSC::Lexer<T>::fillTokenInfo): (JSC::Lexer<T>::lex): (JSC::Lexer<T>::scanRegExp): (JSC::Lexer<T>::scanTrailingTemplateString): (JSC::Lexer<T>::skipRegExp): Deleted. * parser/Lexer.h: (JSC::Lexer::getToken): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseAssignmentExpression): * parser/Parser.h: (JSC::Parser::getToken): * parser/ParserTokens.h: LayoutTests: * fast/regex/dom/non-pattern-characters-expected.txt: * js/arrowfunction-syntax-errors-expected.txt: * js/regexp-compile-crash-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A4_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A4_T4-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.2_T2-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.3_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.3_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.5_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.5_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.2_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.3_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.3_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.5_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.5_T3-expected.txt: Canonical link: https://commits.webkit.org/181658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207798 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-25 02:35:59 +00:00
PASS var y = x=>/ threw exception SyntaxError: Unterminated regular expression literal '/'.
Source/JavaScriptCore: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function. https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc. This patch implements the simplest cases of arrow function declaration: parameters () => 10 + 20 parameter x => x + 20 parameters (x, y) => x + y function with block x => { return x*10; } Not implemented: bind of the this, arguments, super and etc. exception in case of trying to use 'new' with arrow function Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * parser/ASTBuilder.h: (JSC::ASTBuilder::createFunctionExpr): (JSC::ASTBuilder::createArrowFunctionExpr): (JSC::ASTBuilder::createGetterOrSetterProperty): (JSC::ASTBuilder::createFuncDeclStatement): * parser/Lexer.cpp: (JSC::Lexer<T>::setTokenPosition): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::lastTokenLocation): (JSC::Lexer::setTerminator): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseSourceElements): (JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody): (JSC::Parser<LexerType>::parseSwitchClauses): (JSC::Parser<LexerType>::parseSwitchDefaultClause): (JSC::Parser<LexerType>::parseBlockStatement): (JSC::Parser<LexerType>::parseFunctionBody): (JSC::stringForFunctionMode): (JSC::Parser<LexerType>::parseFunctionParameters): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): (JSC::Parser<LexerType>::parseAssignmentExpression): (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parseGetterSetter): (JSC::Parser<LexerType>::parseArrowFunctionExpression): * parser/Parser.h: (JSC::Parser::locationBeforeLastToken): (JSC::Parser::isEndOfArrowFunction): (JSC::Parser::isArrowFunctionParamters): (JSC::Parser::setEndOfStatement): * parser/ParserFunctionInfo.h: * parser/ParserTokens.h: * parser/SourceCode.h: (JSC::SourceCode::subArrowExpression): * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::endFunctionToken): (JSC::SourceProviderCacheItem::SourceProviderCacheItem): * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createArrowFunctionExpr): (JSC::SyntaxChecker::setFunctionNameStart): LayoutTests: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added arrow function tests Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * js/arrowfunction-asparamter-1-expected.txt: Added. * js/arrowfunction-asparamter-1.html: Added. * js/arrowfunction-asparamter-2-expected.txt: Added. * js/arrowfunction-asparamter-2.html: Added. * js/arrowfunction-associativity-1-expected.txt: Added. * js/arrowfunction-associativity-1.html: Added. * js/arrowfunction-associativity-2-expected.txt: Added. * js/arrowfunction-associativity-2.html: Added. * js/arrowfunction-block-1-expected.txt: Added. * js/arrowfunction-block-1.html: Added. * js/arrowfunction-block-2-expected.txt: Added. * js/arrowfunction-block-2.html: Added. * js/arrowfunction-syntax-endings-expected.txt: Added. * js/arrowfunction-syntax-endings.html: Added. * js/arrowfunction-syntax-errors-expected.txt: Added. * js/arrowfunction-syntax-errors.html: Added. * js/arrowfunction-syntax-expected.txt: Added. * js/arrowfunction-syntax.html: Added. * js/script-tests/arrowfunction-asparamter-1.js: Added. * js/script-tests/arrowfunction-asparamter-2.js: Added. * js/script-tests/arrowfunction-associativity-1.js: Added. * js/script-tests/arrowfunction-associativity-2.js: Added. * js/script-tests/arrowfunction-block-1.js: Added. * js/script-tests/arrowfunction-block-2.js: Added. * js/script-tests/arrowfunction-syntax-endings.js: Added. * js/script-tests/arrowfunction-syntax-errors.js: Added. * js/script-tests/arrowfunction-syntax.js: Added. Canonical link: https://commits.webkit.org/164423@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-06-26 06:49:20 +00:00
PASS var y = x=>% threw exception SyntaxError: Unexpected token '%'.
PASS var y = x=>+ threw exception SyntaxError: Unexpected end of script.
PASS var y = x=>- threw exception SyntaxError: Unexpected end of script.
PASS var y = x=><< threw exception SyntaxError: Unexpected token '<<'.
PASS var y = x=>>> threw exception SyntaxError: Unexpected token '>>'.
PASS var y = x=>>>> threw exception SyntaxError: Unexpected token '>>>'.
PASS var y = x=>< threw exception SyntaxError: Unexpected token '<'.
PASS var y = x=>> threw exception SyntaxError: Unexpected token '>'.
PASS var y = x=><= threw exception SyntaxError: Unexpected token '<='.
PASS var y = x=>>= threw exception SyntaxError: Unexpected token '>='.
PASS var y = x=>instanceof threw exception SyntaxError: Unexpected keyword 'instanceof'.
PASS var y = x=>in threw exception SyntaxError: Unexpected keyword 'in'.
PASS var y = x=>== threw exception SyntaxError: Unexpected token '=='.
PASS var y = x=>!= threw exception SyntaxError: Unexpected token '!='.
PASS var y = x=>=== threw exception SyntaxError: Unexpected token '==='.
PASS var y = x=>!== threw exception SyntaxError: Unexpected token '!=='.
PASS var y = x=>& threw exception SyntaxError: Unexpected token '&'.
PASS var y = x=>^ threw exception SyntaxError: Unexpected token '^'.
PASS var y = x=>| threw exception SyntaxError: Unexpected token '|'.
PASS var y = x=>&& threw exception SyntaxError: Unexpected token '&&'.
PASS var y = x=>|| threw exception SyntaxError: Unexpected token '||'.
PASS var y = x=>; threw exception SyntaxError: Unexpected token ';'.
PASS var y = x=>, threw exception SyntaxError: Unexpected token ','.
PASS var y = x=>{ threw exception SyntaxError: Unexpected end of script.
PASS var y = x=>{* threw exception SyntaxError: Unexpected token '*'.
Arrow functions with concise bodies cannot return regular expressions https://bugs.webkit.org/show_bug.cgi?id=163162 Reviewed by Filip Pizlo. JSTests: * ChakraCore/test/Operators/instanceof.baseline-jsc: * ChakraCore/test/Regex/nul_character.baseline-jsc: * ChakraCore/test/es5/Lex_u3.baseline-jsc: * stress/parse-regexp-as-token.js: Added. (shouldBe): Source/JavaScriptCore: When we encounter the RegExp in the parser, we first scan it as / or /=. And if / or /= is parsed under the primary expression context, we rescan it as RegExp. However, we did not update the token record information. So the token record still says "I'm / or /=". When we parse the string "() => /hello/", the last token becomes "/", which is the first character of the RegExp, instead of "/hello/". Since the arrow function parsing utilizes the end offset of the last token, we accidentally recognize the range of the above arrow function as "() => /". In this patch, we update the token when rescanning under the RegExp context. This logic is similar to parsing Tail Template Literal token. We also refine the error message for regular expression literals. And since the REGEXP token is now introduced, the other error messages using that token are improved too. Currently, unterminated error messages can be seen in Parser.cpp. However, these messages cannot be shown to users if the lexer has m_error. So these code is meaningless. I'll move these tokenizing errors to the lexer in the subsequent patch[1]. [1]: https://bugs.webkit.org/show_bug.cgi?id=163928 * parser/Lexer.cpp: (JSC::Lexer<T>::fillTokenInfo): (JSC::Lexer<T>::lex): (JSC::Lexer<T>::scanRegExp): (JSC::Lexer<T>::scanTrailingTemplateString): (JSC::Lexer<T>::skipRegExp): Deleted. * parser/Lexer.h: (JSC::Lexer::getToken): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseAssignmentExpression): * parser/Parser.h: (JSC::Parser::getToken): * parser/ParserTokens.h: LayoutTests: * fast/regex/dom/non-pattern-characters-expected.txt: * js/arrowfunction-syntax-errors-expected.txt: * js/regexp-compile-crash-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A4_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.4_Comments/S7.4_A4_T4-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.2_T2-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.3_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.3_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.5_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A1.5_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.2_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.3_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.3_T3-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.5_T1-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.8_Literals/7.8.5_Regular_Expression_Literals/S7.8.5_A2.5_T3-expected.txt: Canonical link: https://commits.webkit.org/181658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207798 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-25 02:35:59 +00:00
PASS var y = x=>{/ threw exception SyntaxError: Unterminated regular expression literal '/'.
Source/JavaScriptCore: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function. https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc. This patch implements the simplest cases of arrow function declaration: parameters () => 10 + 20 parameter x => x + 20 parameters (x, y) => x + y function with block x => { return x*10; } Not implemented: bind of the this, arguments, super and etc. exception in case of trying to use 'new' with arrow function Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * parser/ASTBuilder.h: (JSC::ASTBuilder::createFunctionExpr): (JSC::ASTBuilder::createArrowFunctionExpr): (JSC::ASTBuilder::createGetterOrSetterProperty): (JSC::ASTBuilder::createFuncDeclStatement): * parser/Lexer.cpp: (JSC::Lexer<T>::setTokenPosition): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::lastTokenLocation): (JSC::Lexer::setTerminator): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseSourceElements): (JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody): (JSC::Parser<LexerType>::parseSwitchClauses): (JSC::Parser<LexerType>::parseSwitchDefaultClause): (JSC::Parser<LexerType>::parseBlockStatement): (JSC::Parser<LexerType>::parseFunctionBody): (JSC::stringForFunctionMode): (JSC::Parser<LexerType>::parseFunctionParameters): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): (JSC::Parser<LexerType>::parseAssignmentExpression): (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parseGetterSetter): (JSC::Parser<LexerType>::parseArrowFunctionExpression): * parser/Parser.h: (JSC::Parser::locationBeforeLastToken): (JSC::Parser::isEndOfArrowFunction): (JSC::Parser::isArrowFunctionParamters): (JSC::Parser::setEndOfStatement): * parser/ParserFunctionInfo.h: * parser/ParserTokens.h: * parser/SourceCode.h: (JSC::SourceCode::subArrowExpression): * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::endFunctionToken): (JSC::SourceProviderCacheItem::SourceProviderCacheItem): * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createArrowFunctionExpr): (JSC::SyntaxChecker::setFunctionNameStart): LayoutTests: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added arrow function tests Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * js/arrowfunction-asparamter-1-expected.txt: Added. * js/arrowfunction-asparamter-1.html: Added. * js/arrowfunction-asparamter-2-expected.txt: Added. * js/arrowfunction-asparamter-2.html: Added. * js/arrowfunction-associativity-1-expected.txt: Added. * js/arrowfunction-associativity-1.html: Added. * js/arrowfunction-associativity-2-expected.txt: Added. * js/arrowfunction-associativity-2.html: Added. * js/arrowfunction-block-1-expected.txt: Added. * js/arrowfunction-block-1.html: Added. * js/arrowfunction-block-2-expected.txt: Added. * js/arrowfunction-block-2.html: Added. * js/arrowfunction-syntax-endings-expected.txt: Added. * js/arrowfunction-syntax-endings.html: Added. * js/arrowfunction-syntax-errors-expected.txt: Added. * js/arrowfunction-syntax-errors.html: Added. * js/arrowfunction-syntax-expected.txt: Added. * js/arrowfunction-syntax.html: Added. * js/script-tests/arrowfunction-asparamter-1.js: Added. * js/script-tests/arrowfunction-asparamter-2.js: Added. * js/script-tests/arrowfunction-associativity-1.js: Added. * js/script-tests/arrowfunction-associativity-2.js: Added. * js/script-tests/arrowfunction-block-1.js: Added. * js/script-tests/arrowfunction-block-2.js: Added. * js/script-tests/arrowfunction-syntax-endings.js: Added. * js/script-tests/arrowfunction-syntax-errors.js: Added. * js/script-tests/arrowfunction-syntax.js: Added. Canonical link: https://commits.webkit.org/164423@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-06-26 06:49:20 +00:00
PASS var y = x=>{% threw exception SyntaxError: Unexpected token '%'.
PASS var y = x=>{+ threw exception SyntaxError: Unexpected end of script.
PASS var y = x=>{- threw exception SyntaxError: Unexpected end of script.
PASS var y = x=>{<< threw exception SyntaxError: Unexpected token '<<'.
PASS var y = x=>{>> threw exception SyntaxError: Unexpected token '>>'.
PASS var y = x=>{>>> threw exception SyntaxError: Unexpected token '>>>'.
PASS var y = x=>{< threw exception SyntaxError: Unexpected token '<'.
PASS var y = x=>{> threw exception SyntaxError: Unexpected token '>'.
PASS var y = x=>{<= threw exception SyntaxError: Unexpected token '<='.
PASS var y = x=>{>= threw exception SyntaxError: Unexpected token '>='.
PASS var y = x=>{instanceof threw exception SyntaxError: Unexpected keyword 'instanceof'.
PASS var y = x=>{in threw exception SyntaxError: Unexpected keyword 'in'.
PASS var y = x=>{== threw exception SyntaxError: Unexpected token '=='.
PASS var y = x=>{!= threw exception SyntaxError: Unexpected token '!='.
PASS var y = x=>{=== threw exception SyntaxError: Unexpected token '==='.
PASS var y = x=>{!== threw exception SyntaxError: Unexpected token '!=='.
PASS var y = x=>{& threw exception SyntaxError: Unexpected token '&'.
PASS var y = x=>{^ threw exception SyntaxError: Unexpected token '^'.
PASS var y = x=>{| threw exception SyntaxError: Unexpected token '|'.
PASS var y = x=>{&& threw exception SyntaxError: Unexpected token '&&'.
PASS var y = x=>{|| threw exception SyntaxError: Unexpected token '||'.
PASS var y = x=>{; threw exception SyntaxError: Unexpected end of script.
PASS var y = x=>{, threw exception SyntaxError: Unexpected token ','.
PASS var y = x=>} threw exception SyntaxError: Unexpected token '}'.
PASS var t = x=>x+1; =>{} threw exception SyntaxError: Unexpected token '=>'.
PASS [=>x+1] threw exception SyntaxError: Unexpected token '=>'.
PASS [x=>x+1, =>x+1] threw exception SyntaxError: Unexpected token '=>'.
PASS var f=>x+1; threw exception SyntaxError: Unexpected token '=>'. Expected ';' after variable declaration..
PASS var x, y=>y+1; threw exception SyntaxError: Unexpected token '=>'. Expected ';' after variable declaration..
PASS debug(=>x+1) threw exception SyntaxError: Unexpected token '=>'.
PASS debug("xyz", =>x+1) threw exception SyntaxError: Unexpected token '=>'.
PASS var af1=y
=>y+1 threw exception SyntaxError: Unexpected token '=>'.
PASS var af2=(y)
=>y+1 threw exception SyntaxError: Unexpected token '=>'.
PASS var af3=(x, y)
=>y+1 threw exception SyntaxError: Unexpected token '=>'.
PASS ([a, b] => a + b)(["a_", "b_"]) threw exception SyntaxError: Unexpected token '=>'. Expected ')' to end a compound expression..
PASS ({a, b} => a + b)({a:"a_", b:"b_"}) threw exception SyntaxError: Unexpected token '=>'. Expected ')' to end a compound expression..
PASS ({c:a,d:b} => a + b)({c:"a_", d:"b_"}) threw exception SyntaxError: Unexpected token '=>'. Expected ')' to end a compound expression..
PASS ({c:b,d:a} => a + b)({c:"a_", d:"b_"}) threw exception SyntaxError: Unexpected token '=>'. Expected ')' to end a compound expression..
PASS var arr1 = [a, b] => a + b; threw exception SyntaxError: Unexpected token '=>'. Expected ';' after variable declaration..
PASS var arr2 = {a, b} => a + b; threw exception SyntaxError: Unexpected token '=>'. Expected ';' after variable declaration..
PASS var arr3 = {c:a,d:b} => a + b; threw exception SyntaxError: Unexpected token '=>'. Expected ';' after variable declaration..
PASS var arr3 = {c:b,d:a} => a + b; threw exception SyntaxError: Unexpected token '=>'. Expected ';' after variable declaration..
super should be available in object literals https://bugs.webkit.org/show_bug.cgi?id=156933 Reviewed by Saam Barati. Source/JavaScriptCore: When we originally implemented classes, super seemed to be a class-only feature. But the final spec says it's available in object literals too. * bytecompiler/NodesCodegen.cpp: (JSC::PropertyListNode::emitBytecode): Having 'super' and being a class property are no longer synonymous, so we track two separate variables. (JSC::PropertyListNode::emitPutConstantProperty): Being inside the super branch no longer guarantees that you're a class property, so we decide our attributes and our function name dynamically. * parser/ASTBuilder.h: (JSC::ASTBuilder::createArrowFunctionExpr): (JSC::ASTBuilder::createGetterOrSetterProperty): (JSC::ASTBuilder::createArguments): (JSC::ASTBuilder::createArgumentsList): (JSC::ASTBuilder::createProperty): (JSC::ASTBuilder::createPropertyList): Pass through state to indicate whether we're a class property, since we can't infer it from 'super' anymore. * parser/NodeConstructors.h: (JSC::PropertyNode::PropertyNode): See ASTBuilder.h. * parser/Nodes.h: (JSC::PropertyNode::expressionName): (JSC::PropertyNode::name): (JSC::PropertyNode::type): (JSC::PropertyNode::needsSuperBinding): (JSC::PropertyNode::isClassProperty): (JSC::PropertyNode::putType): See ASTBuilder.h. * parser/Parser.cpp: (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseClass): (JSC::Parser<LexerType>::parseProperty): (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parseGetterSetter): (JSC::Parser<LexerType>::parseMemberExpression): I made these error messages generic because it is no longer practical to say concise things about the list of places you can use super. * parser/Parser.h: * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createArgumentsList): (JSC::SyntaxChecker::createProperty): (JSC::SyntaxChecker::appendExportSpecifier): (JSC::SyntaxChecker::appendConstDecl): (JSC::SyntaxChecker::createGetterOrSetterProperty): Updated for interface change. * tests/stress/generator-with-super.js: (test): * tests/stress/modules-syntax-error.js: * tests/stress/super-in-lexical-scope.js: (testSyntaxError): (testSyntaxError.test): * tests/stress/tagged-templates-syntax.js: Updated for error message changes. See Parser.cpp. LayoutTests: Updated expected results and added a few new tests. * js/arrowfunction-syntax-errors-expected.txt: * js/class-syntax-super-expected.txt: * js/object-literal-methods-expected.txt: * js/script-tests/arrowfunction-syntax-errors.js: * js/script-tests/class-syntax-super.js: * js/script-tests/object-literal-methods.js: Canonical link: https://commits.webkit.org/175044@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199927 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-04-22 23:04:55 +00:00
PASS var arr4 = () => { super(); }; threw exception SyntaxError: super is not valid in this context..
PASS var arr4 = () => { super; }; threw exception SyntaxError: super is not valid in this context..
PASS var arr5 = () => { super.getValue(); }; threw exception SyntaxError: super is not valid in this context..
PASS var arr6 = () => super(); threw exception SyntaxError: super is not valid in this context..
PASS var arr7 = () => super; threw exception SyntaxError: super is not valid in this context..
PASS var arr8 = () => super.getValue(); threw exception SyntaxError: super is not valid in this context..
PASS class A { constructor() { function a () { return () => { super(); };}} threw exception SyntaxError: super is not valid in this context..
PASS class B { constructor() { function b () { return () => { super; }; }; }} threw exception SyntaxError: super is not valid in this context..
PASS class C { constructor() { function c () { return () => { super.getValue(); };}} threw exception SyntaxError: super is not valid in this context..
PASS class D { constructor() { function a () { return () => super(); }} threw exception SyntaxError: super is not valid in this context..
PASS class E { constructor() { function b () { return () => super; }; }} threw exception SyntaxError: super is not valid in this context..
PASS class F { constructor() { function c () { return () => super.getValue(); }} threw exception SyntaxError: super is not valid in this context..
PASS class G {}; class G2 extends G { getValue() { function c () { return () => super.getValue(); }} threw exception SyntaxError: super is not valid in this context..
PASS class H {}; class H2 extends H { method() { function *gen() { let arr = () => super.getValue(); arr(); } } } threw exception SyntaxError: super is not valid in this context..
Source/JavaScriptCore: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function. https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc. This patch implements the simplest cases of arrow function declaration: parameters () => 10 + 20 parameter x => x + 20 parameters (x, y) => x + y function with block x => { return x*10; } Not implemented: bind of the this, arguments, super and etc. exception in case of trying to use 'new' with arrow function Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * parser/ASTBuilder.h: (JSC::ASTBuilder::createFunctionExpr): (JSC::ASTBuilder::createArrowFunctionExpr): (JSC::ASTBuilder::createGetterOrSetterProperty): (JSC::ASTBuilder::createFuncDeclStatement): * parser/Lexer.cpp: (JSC::Lexer<T>::setTokenPosition): (JSC::Lexer<T>::lex): * parser/Lexer.h: (JSC::Lexer::lastTokenLocation): (JSC::Lexer::setTerminator): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseSourceElements): (JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody): (JSC::Parser<LexerType>::parseSwitchClauses): (JSC::Parser<LexerType>::parseSwitchDefaultClause): (JSC::Parser<LexerType>::parseBlockStatement): (JSC::Parser<LexerType>::parseFunctionBody): (JSC::stringForFunctionMode): (JSC::Parser<LexerType>::parseFunctionParameters): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): (JSC::Parser<LexerType>::parseAssignmentExpression): (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parseGetterSetter): (JSC::Parser<LexerType>::parseArrowFunctionExpression): * parser/Parser.h: (JSC::Parser::locationBeforeLastToken): (JSC::Parser::isEndOfArrowFunction): (JSC::Parser::isArrowFunctionParamters): (JSC::Parser::setEndOfStatement): * parser/ParserFunctionInfo.h: * parser/ParserTokens.h: * parser/SourceCode.h: (JSC::SourceCode::subArrowExpression): * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::endFunctionToken): (JSC::SourceProviderCacheItem::SourceProviderCacheItem): * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createArrowFunctionExpr): (JSC::SyntaxChecker::setFunctionNameStart): LayoutTests: [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function https://bugs.webkit.org/show_bug.cgi?id=144955 Reviewed by Yusuke Suzuki. Added arrow function tests Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26 * js/arrowfunction-asparamter-1-expected.txt: Added. * js/arrowfunction-asparamter-1.html: Added. * js/arrowfunction-asparamter-2-expected.txt: Added. * js/arrowfunction-asparamter-2.html: Added. * js/arrowfunction-associativity-1-expected.txt: Added. * js/arrowfunction-associativity-1.html: Added. * js/arrowfunction-associativity-2-expected.txt: Added. * js/arrowfunction-associativity-2.html: Added. * js/arrowfunction-block-1-expected.txt: Added. * js/arrowfunction-block-1.html: Added. * js/arrowfunction-block-2-expected.txt: Added. * js/arrowfunction-block-2.html: Added. * js/arrowfunction-syntax-endings-expected.txt: Added. * js/arrowfunction-syntax-endings.html: Added. * js/arrowfunction-syntax-errors-expected.txt: Added. * js/arrowfunction-syntax-errors.html: Added. * js/arrowfunction-syntax-expected.txt: Added. * js/arrowfunction-syntax.html: Added. * js/script-tests/arrowfunction-asparamter-1.js: Added. * js/script-tests/arrowfunction-asparamter-2.js: Added. * js/script-tests/arrowfunction-associativity-1.js: Added. * js/script-tests/arrowfunction-associativity-2.js: Added. * js/script-tests/arrowfunction-block-1.js: Added. * js/script-tests/arrowfunction-block-2.js: Added. * js/script-tests/arrowfunction-syntax-endings.js: Added. * js/script-tests/arrowfunction-syntax-errors.js: Added. * js/script-tests/arrowfunction-syntax.js: Added. Canonical link: https://commits.webkit.org/164423@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-06-26 06:49:20 +00:00
PASS successfullyParsed is true
TEST COMPLETE