summaryrefslogtreecommitdiff
path: root/js/src/json.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/json.cpp')
-rw-r--r--js/src/json.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/js/src/json.cpp b/js/src/json.cpp
index f3cf22dac9..d426fc721a 100644
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -9,6 +9,8 @@
#include "mozilla/Range.h"
#include "mozilla/ScopeExit.h"
+#include "builtin/BigInt.h"
+
#include "jsarray.h"
#include "jsatom.h"
#include "jscntxt.h"
@@ -328,6 +330,8 @@ PreprocessValue(JSContext* cx, HandleObject holder, KeyType key, MutableHandleVa
} else if (cls == ESClass::Boolean) {
if (!Unbox(cx, obj, vp))
return false;
+ } else if (cls == ESClass::BigInt) {
+ vp.setBigInt(obj->as<BigIntObject>().unbox());
}
}
@@ -626,6 +630,12 @@ Str(JSContext* cx, const Value& v, StringifyContext* scx)
return NumberValueToStringBuffer(cx, v, scx->sb);
}
+ /* Step 10 in the BigInt proposal. */
+ if (v.isBigInt()) {
+ JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BIGINT_NOT_SERIALIZABLE);
+ return false;
+ }
+
/* Step 10. */
MOZ_ASSERT(v.isObject());
RootedObject obj(cx, &v.toObject());