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

Side by Side Diff: src/parsing/parser.cc

Issue 1485943002: Defer CONST_LEGACY redeclaration errors until runtime in harmony mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/mjsunit/regress/regress-4576.js » ('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 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-literal-reindexer.h" 9 #include "src/ast/ast-literal-reindexer.h"
10 #include "src/ast/scopeinfo.h" 10 #include "src/ast/scopeinfo.h"
(...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 // functions. The function CheckConflictingVarDeclarations checks for 2086 // functions. The function CheckConflictingVarDeclarations checks for
2087 // var and let bindings from different scopes whereas this is a check for 2087 // var and let bindings from different scopes whereas this is a check for
2088 // conflicting declarations within the same scope. This check also covers 2088 // conflicting declarations within the same scope. This check also covers
2089 // the special case 2089 // the special case
2090 // 2090 //
2091 // function () { let x; { var x; } } 2091 // function () { let x; { var x; } }
2092 // 2092 //
2093 // because the var declaration is hoisted to the function scope where 'x' 2093 // because the var declaration is hoisted to the function scope where 'x'
2094 // is already bound. 2094 // is already bound.
2095 DCHECK(IsDeclaredVariableMode(var->mode())); 2095 DCHECK(IsDeclaredVariableMode(var->mode()));
2096 if (is_strict(language_mode()) || allow_harmony_sloppy()) { 2096 if (is_strict(language_mode()) ||
2097 (allow_harmony_sloppy() && mode != CONST_LEGACY &&
2098 var->mode() != CONST_LEGACY)) {
2097 // In harmony we treat re-declarations as early errors. See 2099 // In harmony we treat re-declarations as early errors. See
2098 // ES5 16 for a definition of early errors. 2100 // ES5 16 for a definition of early errors.
2099 if (declaration_kind == DeclarationDescriptor::NORMAL) { 2101 if (declaration_kind == DeclarationDescriptor::NORMAL) {
2100 ParserTraits::ReportMessage(MessageTemplate::kVarRedeclaration, name); 2102 ParserTraits::ReportMessage(MessageTemplate::kVarRedeclaration, name);
2101 } else { 2103 } else {
2102 ParserTraits::ReportMessage(MessageTemplate::kParamDupe); 2104 ParserTraits::ReportMessage(MessageTemplate::kParamDupe);
2103 } 2105 }
2104 *ok = false; 2106 *ok = false;
2105 return nullptr; 2107 return nullptr;
2106 } 2108 }
(...skipping 4348 matching lines...) Expand 10 before | Expand all | Expand 10 after
6455 } 6457 }
6456 6458
6457 6459
6458 void Parser::RaiseLanguageMode(LanguageMode mode) { 6460 void Parser::RaiseLanguageMode(LanguageMode mode) {
6459 SetLanguageMode(scope_, 6461 SetLanguageMode(scope_,
6460 static_cast<LanguageMode>(scope_->language_mode() | mode)); 6462 static_cast<LanguageMode>(scope_->language_mode() | mode));
6461 } 6463 }
6462 6464
6463 } // namespace internal 6465 } // namespace internal
6464 } // namespace v8 6466 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-4576.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698