Function.name property is non-writable. It should be initialized as such.
SimplePropertyDescriptor const JavascriptLibrary::SharedFunctionPropertyDescriptors[2] = { SimplePropertyDescriptor(BuiltInPropertyRecords::prototype, PropertyWritable), SimplePropertyDescriptor(BuiltInPropertyRecords::name, PropertyConfigurable | PropertyWritable) };
this line also needs to be changed: SimpleTypeHandler<1> JavascriptLibrary::SharedFunctionWithoutPrototypeTypeHandler(BuiltInPropertyRecords::name, PropertyConfigurable | PropertyWritable);
And probably clarify that this effects built in function names so creating a test case is easier.
Yes you are right, that needs to be changed as well. I'll look into the existing test case to see what kind of coverage we have there and how can I augment that.
Oh btw, you are welcome to make the change ;)
@farzonl doooooo it :P
Hi, I am not able to reproduce this on current master. My test case is as follows:
var x =[];
print(x.slice.name); // prints slice
x.slice.name = "hello";
print(x.slice.name); // prints slice
Am I doing something wrong?
Ah yes. That's because although we are initializing the name property as writable, when setting the actual name to this property, we set the property attributes as only configurable. So, not a functional bug I guess. But, good to fix as setting attributes different from what were originally there on the property may disable type sharing. For reference, you could see the following code in SimpleTypeHandler<size>::SetPropertyWithAttriutes
SimpleTypeHandler * typeHandler = this;
if (GetIsLocked())
{
#if DBG
DynamicType* oldType = instance->GetDynamicType();
#endif
typeHandler = this->ConvertToNonSharedSimpleType(instance);
#if DBG
Assert(!oldType->GetIsLocked() || instance->GetDynamicType() != oldType);
#endif
}
@rajatd I opened PR #170.