Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 77f85b2fcc7a154814d8bd410bbc31e246347028..8c43d64536c380f3d5d33a7214c332d306931042 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -1172,7 +1172,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { |
return ThrowRedeclarationError(isolate, "const", name); |
} |
// Otherwise, we check for locally conflicting declarations. |
- if (is_local && is_const_property) { |
+ if (is_local && (is_read_only || is_const_property)) { |
const char* type = (is_read_only) ? "const" : "var"; |
return ThrowRedeclarationError(isolate, type, name); |
} |
@@ -1406,11 +1406,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
// make sure to introduce it. |
found = false; |
} else if ((intercepted & READ_ONLY) != 0) { |
- // The property is present, but read-only, so we ignore the |
- // redeclaration. However if we found readonly property |
+ // The property is present, but read-only. Since we're trying to |
+ // overwrite it with a variable declaration we must throw a |
+ // re-declaration error. However if we found readonly property |
// on one of hidden prototypes, just shadow it. |
if (real_holder != isolate->context()->global()) break; |
- return isolate->heap()->undefined_value(); |
+ return ThrowRedeclarationError(isolate, "const", name); |
} |
} |