You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[MERGE #5405@rhuanjl] Fix configurability of function.length and boundFunction.length
Merge pull request #5405 from rhuanjl:boundFunction
Fix: #4122
This PR addresses several issues with the length property of JavascriptFunctions and BoundFunctions.
Length should be configurable (previously worked for JavascriptFunctions but not BoundFunctions)
Deleting length should succeed (previously failed for both)
Deleting length should not throw in strict mode (previously failed for both)
value after deletion = 0 (previously failed for both)
using defineProperty to redefine length should work (previously failed silently for both)
Copy file name to clipboardexpand all lines: lib/Runtime/Library/BoundFunction.cpp
+13-178
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,6 @@ namespace Js
24
24
count(0),
25
25
boundArgs(nullptr)
26
26
{
27
-
28
27
DebugOnly(VerifyEntryPoint());
29
28
AssertMsg(args.Info.Count > 0, "wrong number of args in BoundFunction");
30
29
@@ -44,21 +43,19 @@ namespace Js
44
43
}
45
44
type->SetPrototype(proto);
46
45
}
46
+
47
+
int len = 0;
47
48
// If targetFunction is proxy, need to make sure that traps are called in right order as per 19.2.3.2 in RC#4 dated April 3rd 2015.
48
-
//Here although we won't use value of length, this is just to make sure that we call traps involved with HasOwnProperty(Target, "length") and Get(Target, "length")
49
-
if (JavascriptProxy::Is(targetFunction))
49
+
//additionally need to get the correct length value for the boundFunctions' length property
50
+
if (JavascriptOperators::HasOwnProperty(targetFunction, PropertyIds::length, scriptContext, nullptr) == TRUE)
50
51
{
51
-
if (JavascriptOperators::HasOwnProperty(targetFunction, PropertyIds::length, scriptContext, nullptr) == TRUE)
52
+
Var varLength;
53
+
if (targetFunction->GetProperty(targetFunction, PropertyIds::length, &varLength, nullptr, scriptContext))
52
54
{
53
-
int len = 0;
54
-
Var varLength;
55
-
if (targetFunction->GetProperty(targetFunction, PropertyIds::length, &varLength, nullptr, scriptContext))
56
-
{
57
-
len = JavascriptConversion::ToInt32(varLength, scriptContext);
58
-
}
55
+
len = JavascriptConversion::ToInt32(varLength, scriptContext);
0 commit comments