Skip to content

Commit

Permalink
feat: Maximum number of enum cases is now 16777215 instead of 255
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed Jan 30, 2025
1 parent 71528bd commit a48aff6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7306,7 +7306,7 @@ fn enumDeclaration(self: *Self) Error!Ast.Node.Index {
var picked = std.ArrayList(bool).init(self.gc.allocator);
var case_index: i32 = 0;
while (!self.check(.RightBrace) and !self.check(.Eof)) : (case_index += 1) {
if (case_index > std.math.maxInt(u8)) {
if (case_index > std.math.maxInt(u24)) {
self.reportError(.enum_cases_count, "Too many enum cases.");
}

Expand Down
2 changes: 1 addition & 1 deletion src/obj.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4208,7 +4208,7 @@ pub const ObjEnumInstance = struct {
obj: Obj = .{ .obj_type = .EnumInstance },

enum_ref: *ObjEnum,
case: u8,
case: u24,

pub fn mark(self: *Self, gc: *GarbageCollector) !void {
try gc.markObj(self.enum_ref.toObj());
Expand Down
2 changes: 1 addition & 1 deletion src/vm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ pub const VM = struct {
ObjEnumInstance,
ObjEnumInstance{
.enum_ref = enum_,
.case = @intCast(arg),
.case = arg,
},
) catch {
self.panic("Out of memory");
Expand Down

0 comments on commit a48aff6

Please sign in to comment.