1.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Wed Oct 30 20:09:44 2013 +0530 1.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Fri Nov 01 19:54:48 2013 +0530 1.3 @@ -226,14 +226,23 @@ 1.4 1.5 for (final Property property : properties) { 1.6 final String key = property.getKey(); 1.7 - 1.8 - if (newMap.findProperty(key) == null) { 1.9 + final Property oldProp = newMap.findProperty(key); 1.10 + if (oldProp == null) { 1.11 if (property instanceof UserAccessorProperty) { 1.12 final UserAccessorProperty prop = this.newUserAccessors(key, property.getFlags(), property.getGetterFunction(source), property.getSetterFunction(source)); 1.13 newMap = newMap.addProperty(prop); 1.14 } else { 1.15 newMap = newMap.addPropertyBind((AccessorProperty)property, source); 1.16 } 1.17 + } else { 1.18 + // See ECMA section 10.5 Declaration Binding Instantiation 1.19 + // step 5 processing each function declaration. 1.20 + if (property.isFunctionDeclaration() && !oldProp.isConfigurable()) { 1.21 + if (oldProp instanceof UserAccessorProperty || 1.22 + !(oldProp.isWritable() && oldProp.isEnumerable())) { 1.23 + throw typeError("cant.redefine.property", key, ScriptRuntime.safeToString(this)); 1.24 + } 1.25 + } 1.26 } 1.27 } 1.28