Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: src/parsing/parser-base.h

Issue 2139063002: [parser] report errors for invalid binding patterns in async formal parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Cleanups Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/hashmap.h" 10 #include "src/base/hashmap.h"
(...skipping 2809 matching lines...) Expand 10 before | Expand all | Expand 10 after
2820 // with positions recorded for function literal and confuse debugger. 2820 // with positions recorded for function literal and confuse debugger.
2821 pos = peek_position(); 2821 pos = peek_position();
2822 // Also the trailing parenthesis are a hint that the function will 2822 // Also the trailing parenthesis are a hint that the function will
2823 // be called immediately. If we happen to have parsed a preceding 2823 // be called immediately. If we happen to have parsed a preceding
2824 // function literal eagerly, we can also compile it eagerly. 2824 // function literal eagerly, we can also compile it eagerly.
2825 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { 2825 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
2826 result->AsFunctionLiteral()->set_should_eager_compile(); 2826 result->AsFunctionLiteral()->set_should_eager_compile();
2827 } 2827 }
2828 } 2828 }
2829 Scanner::Location spread_pos; 2829 Scanner::Location spread_pos;
2830 typename Traits::Type::ExpressionList args = 2830 typename Traits::Type::ExpressionList args;
2831 ParseArguments(&spread_pos, is_async, classifier, CHECK_OK); 2831 if (V8_UNLIKELY(is_async)) {
2832 2832 ExpressionClassifier async_classifier(this);
2833 if (V8_UNLIKELY(is_async && peek() == Token::ARROW)) { 2833 args = ParseArguments(&spread_pos, true, &async_classifier, CHECK_OK);
2834 if (args->length()) { 2834 if (peek() == Token::ARROW) {
2835 // async ( Arguments ) => ... 2835 ValidateBindingPattern(&async_classifier, CHECK_OK);
2836 return Traits::ExpressionListToExpression(args); 2836 if (!async_classifier.is_valid_async_arrow_formal_parameters()) {
2837 ReportClassifierError(
2838 async_classifier.async_arrow_formal_parameters_error());
2839 *ok = false;
2840 return this->EmptyExpression();
2841 }
2842 if (args->length()) {
2843 // async ( Arguments ) => ...
2844 return Traits::ExpressionListToExpression(args);
2845 }
2846 // async () => ...
2847 return factory()->NewEmptyParentheses(pos);
2848 } else {
2849 classifier->Accumulate(&async_classifier,
2850 ExpressionClassifier::AllProductions);
2837 } 2851 }
2838 // async () => ... 2852 } else {
2839 return factory()->NewEmptyParentheses(pos); 2853 args = ParseArguments(&spread_pos, false, classifier, CHECK_OK);
2840 } 2854 }
2841 2855
2842 ArrowFormalParametersUnexpectedToken(classifier); 2856 ArrowFormalParametersUnexpectedToken(classifier);
2843 2857
2844 // Keep track of eval() calls since they disable all local variable 2858 // Keep track of eval() calls since they disable all local variable
2845 // optimizations. 2859 // optimizations.
2846 // The calls that need special treatment are the 2860 // The calls that need special treatment are the
2847 // direct eval calls. These calls are all of the form eval(...), with 2861 // direct eval calls. These calls are all of the form eval(...), with
2848 // no explicit receiver. 2862 // no explicit receiver.
2849 // These calls are marked as potentially direct eval calls. Whether 2863 // These calls are marked as potentially direct eval calls. Whether
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
3651 has_seen_constructor_ = true; 3665 has_seen_constructor_ = true;
3652 return; 3666 return;
3653 } 3667 }
3654 } 3668 }
3655 3669
3656 3670
3657 } // namespace internal 3671 } // namespace internal
3658 } // namespace v8 3672 } // namespace v8
3659 3673
3660 #endif // V8_PARSING_PARSER_BASE_H 3674 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698