diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index 1d656d20a5..8a51a4a7e9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp @@ -41,6 +41,10 @@ ThrowCompletionOr NumberFormatFunction::call() // 4. Let x be ? ToNumeric(value). value = TRY(value.to_numeric(global_object)); + // FIXME: Support BigInt number formatting. + if (value.is_bigint()) + return vm.throw_completion(global_object, ErrorType::NotImplemented, "BigInt number formatting"); + // 5. Return ? FormatNumeric(nf, x). // Note: Our implementation of FormatNumeric does not throw. auto formatted = format_numeric(m_number_format, value.as_double()); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.format.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.format.js index 7e388c5f83..11dcdac25c 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.format.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.format.js @@ -14,6 +14,16 @@ describe("errors", () => { Intl.NumberFormat().format(Symbol.hasInstance); }).toThrowWithMessage(TypeError, "Cannot convert symbol to number"); }); + + // FIXME: Remove this and add BigInt tests when BigInt number formatting is supported. + test("bigint", () => { + expect(() => { + Intl.NumberFormat().format(1n); + }).toThrowWithMessage( + InternalError, + "BigInt number formatting is not implemented in LibJS" + ); + }); }); describe("special values", () => {