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

Unified Diff: src/ast/scopes.h

Issue 2119933002: Reland of Add errors for declarations which conflict with catch parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixes per Adam Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.h
diff --git a/src/ast/scopes.h b/src/ast/scopes.h
index b25440b7b0b3318a5d27928d932a30a67f8cafac..0e4da9a301c13854fafc71e70eb0ad5b2ad9905e 100644
--- a/src/ast/scopes.h
+++ b/src/ast/scopes.h
@@ -236,6 +236,14 @@ class Scope: public ZoneObject {
// scope over a let binding of the same name.
Declaration* CheckConflictingVarDeclarations();
+ // Check if the scope has a conflicting lexical declaration that has a name in
+ // the given list. This is used to catch patterns like
+ // `try{}catch(e){let e;}`,
+ // which is an error even though the two 'e's are declared in different
+ // scopes.
+ Declaration* CheckLexDeclarationsConflictingWith(
+ const ZoneList<const AstRawString*>& names);
+
// ---------------------------------------------------------------------------
// Scope-specific info.
@@ -491,6 +499,12 @@ class Scope: public ZoneObject {
// The ModuleDescriptor for this scope; only for module scopes.
ModuleDescriptor* module() const { return module_descriptor_; }
+ const AstRawString* catch_variable_name() const {
+ DCHECK(is_catch_scope());
+ DCHECK(num_var() == 1);
+ return static_cast<AstRawString*>(variables_.Start()->key);
+ }
+
// ---------------------------------------------------------------------------
// Variable allocation.
@@ -501,8 +515,8 @@ class Scope: public ZoneObject {
ZoneList<Variable*>* context_locals,
ZoneList<Variable*>* context_globals);
- // Current number of var or const locals.
- int num_var_or_const() { return num_var_or_const_; }
+ // Current number of var locals.
+ int num_var() const { return num_var_; }
// Result of variable allocation.
int num_stack_slots() const { return num_stack_slots_; }
@@ -673,7 +687,7 @@ class Scope: public ZoneObject {
bool is_declaration_scope_;
// Computed as variables are declared.
- int num_var_or_const_;
+ int num_var_;
// Computed via AllocateVariables; function, block and catch scopes only.
int num_stack_slots_;
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698