Index: src/scopes.cc |
diff --git a/src/scopes.cc b/src/scopes.cc |
index 56a922d25da9395604e210f7847ef498043c6e66..c283b969d37913d30ae2ce0bfd0dcb1be3001c5b 100644 |
--- a/src/scopes.cc |
+++ b/src/scopes.cc |
@@ -308,23 +308,6 @@ bool Scope::Analyze(CompilationInfo* info) { |
} |
#endif |
- if (FLAG_harmony_scoping) { |
- VariableProxy* proxy = scope->CheckAssignmentToConst(); |
- if (proxy != NULL) { |
- // Found an assignment to const. Throw a syntax error. |
- MessageLocation location(info->script(), |
- proxy->position(), |
- proxy->position()); |
- Isolate* isolate = info->isolate(); |
- Factory* factory = isolate->factory(); |
- Handle<JSArray> array = factory->NewJSArray(0); |
- Handle<Object> result = |
- factory->NewSyntaxError("harmony_const_assign", array); |
- isolate->Throw(*result, &location); |
- return false; |
- } |
- } |
- |
info->SetScope(scope); |
return true; |
} |
@@ -591,29 +574,6 @@ Declaration* Scope::CheckConflictingVarDeclarations() { |
} |
-VariableProxy* Scope::CheckAssignmentToConst() { |
- // Check this scope. |
- if (is_extended_mode()) { |
- for (int i = 0; i < unresolved_.length(); i++) { |
- ASSERT(unresolved_[i]->var() != NULL); |
- if (unresolved_[i]->var()->is_const_mode() && |
- unresolved_[i]->IsLValue()) { |
- return unresolved_[i]; |
- } |
- } |
- } |
- |
- // Check inner scopes. |
- for (int i = 0; i < inner_scopes_.length(); i++) { |
- VariableProxy* proxy = inner_scopes_[i]->CheckAssignmentToConst(); |
- if (proxy != NULL) return proxy; |
- } |
- |
- // No assignments to const found. |
- return NULL; |
-} |
- |
- |
class VarAndOrder { |
public: |
VarAndOrder(Variable* var, int order) : var_(var), order_(order) { } |
@@ -1102,6 +1062,20 @@ bool Scope::ResolveVariable(CompilationInfo* info, |
ASSERT(var != NULL); |
+ if (FLAG_harmony_scoping && is_extended_mode() && |
+ var->is_const_mode() && proxy->IsLValue()) { |
+ // Assignment to const. Throw a syntax error. |
+ MessageLocation location( |
+ info->script(), proxy->position(), proxy->position()); |
+ Isolate* isolate = Isolate::Current(); |
+ Factory* factory = isolate->factory(); |
+ Handle<JSArray> array = factory->NewJSArray(0); |
+ Handle<Object> result = |
+ factory->NewSyntaxError("harmony_const_assign", array); |
+ isolate->Throw(*result, &location); |
+ return false; |
+ } |
+ |
if (FLAG_harmony_modules) { |
bool ok; |
#ifdef DEBUG |
@@ -1122,9 +1096,8 @@ bool Scope::ResolveVariable(CompilationInfo* info, |
// Inconsistent use of module. Throw a syntax error. |
// TODO(rossberg): generate more helpful error message. |
- MessageLocation location(info->script(), |
- proxy->position(), |
- proxy->position()); |
+ MessageLocation location( |
+ info->script(), proxy->position(), proxy->position()); |
Isolate* isolate = Isolate::Current(); |
Factory* factory = isolate->factory(); |
Handle<JSArray> array = factory->NewJSArray(1); |