Closed Bug 1528784 Opened 6 years ago Closed 6 years ago

BigInt wrapper passed as receiver when retrieving "toJSON" property in JSON.stringify

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: anba, Assigned: wingo)

References

Details

Attachments

(1 file)

Test case:

Object.defineProperty(BigInt.prototype, "toJSON", {
    get() {
        "use strict";
        return () => typeof this;
    }
});

print(JSON.stringify(0n));

Expected: Prints "bigint"
Actual: Prints "object"

Spec:
Runtime Semantics: SerializeJSONProperty calls GetV which means the primitive value should be passed as the receiver.

Note:
This also fails in V8, so there's probably no test262 test for this case.

Assignee: nobody → wingo
Keywords: checkin-needed

Pushed by apavel@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c6ae678d11d1
Pass BigInt as receiver when retrieving "toJSON" property r=anba

Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: