Index: src/scopes.cc |
diff --git a/src/scopes.cc b/src/scopes.cc |
index 319aca518ed69187dc29cc817c58f9266b2a8700..ce06976c4c9d2369d208d41ccc53a9431f9cba8e 100644 |
--- a/src/scopes.cc |
+++ b/src/scopes.cc |
@@ -593,7 +593,11 @@ class VarAndOrder { |
Variable* var() const { return var_; } |
int order() const { return order_; } |
static int Compare(const VarAndOrder* a, const VarAndOrder* b) { |
- return a->order_ - b->order_; |
+ // Sort lexical variables to the end of the list. |
+ bool a_is_lexical = IsLexicalVariableMode(a->var()->mode()); |
+ bool b_is_lexical = IsLexicalVariableMode(b->var()->mode()); |
+ if (a_is_lexical == b_is_lexical) return a->order_ - b->order_; |
+ return a_is_lexical ? 1 : -1; |
} |
private: |