Skip to content

Commit d4e1efd

Browse files
committed
fix bug with arguments enumerator in JSON.parse
1 parent 0fd7555 commit d4e1efd

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

lib/Runtime/Library/ArgumentsObjectEnumerator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Js
2121
ArgumentsObjectPrefixEnumerator(ArgumentsObject* argumentsObject, EnumeratorFlags flags, ScriptContext* requestContext);
2222
virtual void Reset() override;
2323
virtual JavascriptString * MoveAndGetNext(PropertyId& propertyId, PropertyAttributes* attributes = nullptr) override;
24+
virtual uint32 GetCurrentItemIndex() override { return formalArgIndex; }
2425
};
2526

2627
class ES5ArgumentsObjectEnumerator : public ArgumentsObjectPrefixEnumerator

test/JSON/arguments.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
let set = false;
7+
let a = JSON.parse('["first", null]', function (key, value) {
8+
if(!set) {
9+
this[1] = arguments;
10+
set = true;
11+
}
12+
return value;
13+
});
14+
let passed = JSON.stringify(a) === `["first",{"0":"0","1":"first"}]`;
15+
16+
print(passed ? "Pass" : "Fail")

test/JSON/rlexe.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<tags>exclude_test,Slow</tags>
2828
</default>
2929
</test>
30+
<test>
31+
<default>
32+
<files>arguments.js</files>
33+
</default>
34+
</test>
3035
<test>
3136
<default>
3237
<files>replacerFunction.js</files>

0 commit comments

Comments
 (0)