diff options
author | 2021-09-27 16:28:04 -0700 | |
---|---|---|
committer | 2021-09-27 16:28:04 -0700 | |
commit | 0da19a25cfeb6b0707d663a6c7e84ef1b9545c01 (patch) | |
tree | b8cf32a51802189f97acd18d1f77274455684a83 | |
parent | 3b92a867e247fa2b6ea72ca31d2339c9bf726a30 (diff) | |
download | bun-0da19a25cfeb6b0707d663a6c7e84ef1b9545c01.tar.gz bun-0da19a25cfeb6b0707d663a6c7e84ef1b9545c01.tar.zst bun-0da19a25cfeb6b0707d663a6c7e84ef1b9545c01.zip |
`u16` isn't big enough
-rw-r--r-- | src/javascript/jsc/bindings/bindings.zig | 6 | ||||
-rw-r--r-- | src/js_ast.zig | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index 3355fab44..c510c2bb2 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -1443,10 +1443,14 @@ pub const JSValue = enum(i64) { }); } - pub inline fn toU16(this: JSValue) u36 { + pub inline fn toU16(this: JSValue) u16 { return @intCast(u16, this.toInt32()); } + pub inline fn toU32(this: JSValue) u32 { + return @intCast(u32, this.toInt32()); + } + pub fn getLengthOfArray(this: JSValue, globalThis: *JSGlobalObject) u32 { return cppFn("getLengthOfArray", .{ this, diff --git a/src/js_ast.zig b/src/js_ast.zig index 0a879b8cd..4e1f091d0 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -5898,15 +5898,15 @@ pub const Macro = struct { switch (tag) { .e_array => { // var e_array: E.Array = E.Array{ .items = writer.allocator.alloc(E.Array, args.len) catch return false }; - var count = (writer.nextJSValue() orelse return false).toU16(); - var i: u16 = 0; + var count = (writer.nextJSValue() orelse return false).toU32(); + var i: @TypeOf(count) = 0; var items = ExprList.initCapacity(writer.allocator, count) catch unreachable; while (i < count) { var nextArg = writer.eatArg() orelse return false; if (js.JSValueIsArray(writer.ctx, nextArg.asRef())) { const extras = nextArg.getLengthOfArray(JavaScript.VirtualMachine.vm.global); - count += std.math.max(@truncate(u16, extras), 1) - 1; + count += std.math.max(@truncate(@TypeOf(count), extras), 1) - 1; items.ensureUnusedCapacity(extras) catch unreachable; items.expandToCapacity(); var new_writer = writer.*; @@ -6028,10 +6028,10 @@ pub const Macro = struct { return true; }, .e_object => { - const len = (writer.nextJSValue() orelse return false).toU16(); + const len = (writer.nextJSValue() orelse return false).toU32(); var properties = writer.allocator.alloc(G.Property, len) catch return false; - var property_i: u16 = 0; + var property_i: u32 = 0; while (property_i < properties.len) : (property_i += 1) { switch (TagOrJSNode.fromJSValue(writer, writer.eatArg() orelse return false)) { |