Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the rest of node:buffer #15722

Draft
wants to merge 51 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2a1a431
fix test-buffer-zero-fill-cli.js
nektro Dec 11, 2024
2699eda
fix test-buffer-alloc.js
nektro Dec 11, 2024
5d00fcd
fix test-buffer-bytelength.js
nektro Dec 11, 2024
975a339
fix test-buffer-compare.js
nektro Dec 11, 2024
b2077dd
fix test-buffer-concat.js
nektro Dec 11, 2024
fde51e7
fix test-buffer-constants.js
nektro Dec 11, 2024
0168fa8
fix test-buffer-copy.js
nektro Dec 11, 2024
158c581
fix test-buffer-equals.js
nektro Dec 11, 2024
7535c58
fix test-buffer-fill.js
nektro Dec 11, 2024
814ac87
fix test-buffer-writeuint.js
nektro Dec 11, 2024
ba777b8
fix test-buffer-writeint.js
nektro Dec 11, 2024
bdb9772
fix test-buffer-writefloat.js
nektro Dec 11, 2024
8a9b9f5
fix test-buffer-writedouble.js
nektro Dec 11, 2024
28a7c40
fix test-buffer-write.js
nektro Dec 11, 2024
eef6fc8
fix test-buffer-readuint.js
nektro Dec 11, 2024
89795bf
fix test-buffer-readint.js
nektro Dec 11, 2024
237e4df
fix test-buffer-readfloat.js
nektro Dec 11, 2024
5b650bc
fix test-buffer-readdouble.js
nektro Dec 11, 2024
f108c3c
fix test-buffer-read.js
nektro Dec 12, 2024
ba86ff1
fix test-buffer-new.js
nektro Dec 12, 2024
db74f9c
fix test-buffer-bigint64.js
nektro Dec 12, 2024
af0fd9d
fix test-buffer-backing-arraybuffer.js
nektro Dec 12, 2024
3f810a3
fix test-buffer-arraybuffer.js
nektro Dec 12, 2024
72e5b7e
fixed correctness issue in ERR_INVALID_ARG_TYPE
nektro Dec 12, 2024
8fd46d4
fix regression
nektro Dec 12, 2024
3b3c29e
add scripts/check-node-all.sh
nektro Dec 12, 2024
d13a47f
fix regressions
nektro Dec 12, 2024
d56586e
fix test-buffer-badhex.js
nektro Dec 12, 2024
d45c4d8
fix test-buffer-from.js
nektro Dec 12, 2024
d0eb4a6
fix test-buffer-sharedarraybuffer.js
nektro Dec 12, 2024
58b7515
move main impl of Buffer.from back to JSBufferConstructor
nektro Dec 13, 2024
3778be8
misc fixes
nektro Dec 13, 2024
7a911c1
Merge remote-tracking branch 'origin/main' into nektro-patch-52129
nektro Dec 13, 2024
9dff935
Merge remote-tracking branch 'origin/main' into nektro-patch-52129
nektro Dec 13, 2024
18b2969
fix test-stream-unshift-empty-chunk.js regression
nektro Dec 13, 2024
1cf31b8
webkit upgrade for test-buffer-alloc.js
nektro Dec 13, 2024
e49cc4d
fix test-buffer-indexof.js
nektro Dec 13, 2024
15c4304
fix test-buffer-includes.js
nektro Dec 13, 2024
eeb2803
fix includes on linux, memmem on macos isn't posix compliant
nektro Dec 14, 2024
b692263
fix windows build
nektro Dec 14, 2024
4a332e6
fix linux x64
nektro Dec 14, 2024
befcab8
cleaner name
nektro Dec 14, 2024
48eff0f
share implementation
nektro Dec 14, 2024
37d3472
these commented tests are fixed
nektro Dec 14, 2024
4d49408
only read getters once
nektro Dec 14, 2024
fc3a95d
dont create JSString for ASCIILiteral
nektro Dec 14, 2024
9201b88
address comments
nektro Dec 14, 2024
8b17029
dont create JSString for ASCIILiteral
nektro Dec 14, 2024
ab1e149
Merge branch 'main' into nektro-patch-52129
Jarred-Sumner Dec 15, 2024
c052ebf
Merge branch 'main' into nektro-patch-52129
nektro Dec 23, 2024
3a22eb7
Merge remote-tracking branch 'origin/main' into nektro-patch-52129
nektro Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/bun.js/ConsoleObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,6 @@ pub const FormatOptions = struct {
if (try arg1.getBooleanLoose(globalThis, "sorted")) |opt| {
formatOptions.ordered_properties = opt;
}

if (try arg1.getBooleanLoose(globalThis, "compact")) |opt| {
formatOptions.single_line = opt;
}
Expand Down Expand Up @@ -2262,7 +2261,7 @@ pub const Formatter = struct {
this.addForNewLine(description.len + "()".len);
writer.print(comptime Output.prettyFmt("<r><blue>Symbol({any})<r>", enable_ansi_colors), .{description});
} else {
writer.print(comptime Output.prettyFmt("<r><blue>Symbol<r>", enable_ansi_colors), .{});
writer.print(comptime Output.prettyFmt("<r><blue>Symbol()<r>", enable_ansi_colors), .{});
}
},
.Error => {
Expand Down
21 changes: 17 additions & 4 deletions src/bun.js/bindings/ErrorCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ JSObject* createError(Zig::JSGlobalObject* globalObject, ErrorCode code, JSC::JS
// export fn Bun__inspect(globalThis: *JSGlobalObject, value: JSValue) ZigString
extern "C" ZigString Bun__inspect(JSC::JSGlobalObject* globalObject, JSValue value);

//
WTF::String JSValueToStringSafe(JSC::JSGlobalObject* globalObject, JSValue arg)
{
ASSERT(!arg.isEmpty());
Expand Down Expand Up @@ -379,13 +378,17 @@ WTF::String ERR_INVALID_ARG_TYPE(JSC::ThrowScope& scope, JSC::JSGlobalObject* gl
unsigned length = expected_types.size();
if (length == 1) {
result.append(expected_types.at(0).toWTFString(globalObject));
} else if (length == 2) {
result.append(expected_types.at(0).toWTFString(globalObject));
result.append(", or "_s);
result.append(expected_types.at(1).toWTFString(globalObject));
} else {
for (unsigned i = 0; i < length - 1; i++) {
JSValue expected_type = expected_types.at(i);
if (i > 0) result.append(", "_s);
result.append(expected_type.toWTFString(globalObject));
}
result.append(" or "_s);
result.append(", or "_s);
result.append(expected_types.at(length - 1).toWTFString(globalObject));
}

Expand Down Expand Up @@ -434,6 +437,12 @@ WTF::String ERR_OUT_OF_RANGE(JSC::ThrowScope& scope, JSC::JSGlobalObject* global

namespace ERR {

JSC::EncodedJSValue throwCode(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, ErrorCode code, const WTF::String& message)
{
throwScope.throwException(globalObject, createError(globalObject, code, message));
return {};
}

JSC::EncodedJSValue INVALID_ARG_TYPE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& arg_name, const WTF::String& expected_type, JSC::JSValue val_actual_value)
{
auto arg_kind = arg_name.contains('.') ? "property"_s : "argument"_s;
Expand Down Expand Up @@ -529,7 +538,7 @@ JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObjec
return {};
}

JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, WTF::ASCIILiteral name, JSC::JSValue value, const WTF::String& reason)
JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& name, JSC::JSValue value, const WTF::String& reason)
{
ASCIILiteral type = String(name).contains('.') ? "property"_s : "argument"_s;

Expand Down Expand Up @@ -614,8 +623,12 @@ JSC::EncodedJSValue STRING_TOO_LONG(JSC::ThrowScope& throwScope, JSC::JSGlobalOb
return {};
}

JSC::EncodedJSValue BUFFER_OUT_OF_BOUNDS(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject)
JSC::EncodedJSValue BUFFER_OUT_OF_BOUNDS(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& name)
{
if (!name.isEmpty()) {
throwScope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_BUFFER_OUT_OF_BOUNDS, makeString("\""_s, name, "\" is outside of buffer bounds"_s)));
return {};
}
throwScope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_BUFFER_OUT_OF_BOUNDS, "Attempt to access memory outside buffer bounds"_s));
return {};
}
Expand Down
12 changes: 7 additions & 5 deletions src/bun.js/bindings/ErrorCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ enum Bound {

namespace ERR {

JSC::EncodedJSValue throwCode(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, ErrorCode code, const WTF::String& message);

JSC::EncodedJSValue INVALID_ARG_TYPE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& arg_name, const WTF::String& expected_type, JSC::JSValue val_actual_value);
JSC::EncodedJSValue INVALID_ARG_TYPE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue arg_name, const WTF::String& expected_type, JSC::JSValue val_actual_value);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& arg_name, double lower, double upper, JSC::JSValue actual);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue arg_name, double lower, double upper, JSC::JSValue actual);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue arg_name_val, double bound_num, Bound bound, JSC::JSValue actual);
JSC::EncodedJSValue INVALID_ARG_TYPE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue val_arg_name, const WTF::String& val_expected_type, JSC::JSValue val_actual_value);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& arg_name, size_t lower, size_t upper, JSC::JSValue actual);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue arg_name, size_t lower, size_t upper, JSC::JSValue actual);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue arg_name_val, size_t bound_num, Bound bound, JSC::JSValue actual);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue arg_name_val, const WTF::String& msg, JSC::JSValue actual);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& arg_name_val, const WTF::String& msg, JSC::JSValue actual);
JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, WTF::ASCIILiteral name, JSC::JSValue value, const WTF::String& reason = "is invalid"_s);
Expand All @@ -78,7 +80,7 @@ JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobal
JSC::EncodedJSValue UNKNOWN_ENCODING(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::StringView encoding);
JSC::EncodedJSValue INVALID_STATE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& statemsg);
JSC::EncodedJSValue STRING_TOO_LONG(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject);
JSC::EncodedJSValue BUFFER_OUT_OF_BOUNDS(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject);
JSC::EncodedJSValue BUFFER_OUT_OF_BOUNDS(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& name);
JSC::EncodedJSValue UNKNOWN_SIGNAL(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue signal, bool triedUppercase = false);
JSC::EncodedJSValue SOCKET_BAD_PORT(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue name, JSC::JSValue port, bool allowZero);
JSC::EncodedJSValue UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject);
Expand Down
Loading
Loading