Changeset 214145 in webkit for trunk/Source/JavaScriptCore/runtime/ProgramExecutable.cpp
- Timestamp:
- Mar 19, 2017, 10:45:39 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/ProgramExecutable.cpp
r209897 r214145 73 73 } 74 74 75 // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasrestrictedglobalproperty 76 static bool hasRestrictedGlobalProperty(ExecState* exec, JSGlobalObject* globalObject, PropertyName propertyName) 77 { 78 PropertyDescriptor descriptor; 79 if (!globalObject->getOwnPropertyDescriptor(exec, propertyName, descriptor)) 80 return false; 81 if (descriptor.configurable()) 82 return false; 83 return true; 84 } 85 75 86 JSObject* ProgramExecutable::initializeGlobalProperties(VM& vm, CallFrame* callFrame, JSScope* scope) 76 87 { … … 119 130 // It's an error to introduce a shadow. 120 131 for (auto& entry : lexicalDeclarations) { 121 bool hasProperty = globalObject->hasProperty(exec, entry.key.get()); 122 RETURN_IF_EXCEPTION(throwScope, throwScope.exception()); 123 if (hasProperty) { 124 // The ES6 spec says that just RestrictedGlobalProperty can't be shadowed 125 // This carried out section 8.1.1.4.14 of the ES6 spec: http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasrestrictedglobalproperty 126 PropertyDescriptor descriptor; 127 globalObject->getOwnPropertyDescriptor(exec, entry.key.get(), descriptor); 128 129 if (descriptor.value() != jsUndefined() && !descriptor.configurable()) 130 return createSyntaxError(exec, makeString("Can't create duplicate variable that shadows a global property: '", String(entry.key.get()), "'")); 131 } 132 133 hasProperty = globalLexicalEnvironment->hasProperty(exec, entry.key.get()); 132 // The ES6 spec says that RestrictedGlobalProperty can't be shadowed. 133 if (hasRestrictedGlobalProperty(exec, globalObject, entry.key.get())) 134 return createSyntaxError(exec, makeString("Can't create duplicate variable that shadows a global property: '", String(entry.key.get()), "'")); 135 136 bool hasProperty = globalLexicalEnvironment->hasProperty(exec, entry.key.get()); 134 137 RETURN_IF_EXCEPTION(throwScope, throwScope.exception()); 135 138 if (hasProperty) {
Note:
See TracChangeset
for help on using the changeset viewer.