Skip to content

Commit 746aaec

Browse files
committed
Fix more formatter stuff
1 parent 7258ee8 commit 746aaec

File tree

502 files changed

+6875
-3647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

502 files changed

+6875
-3647
lines changed

crates/cli/tests/benchmarks/platform/app.roc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ app [main!] { pf: platform "main.roc" }
22

33
main! : {} => {}
44
main! = \{} -> {}
5+
boo

src/canonicalize/CIR2.zig

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,8 @@ pub const StmtTag = enum(u8) {
5858
};
5959

6060
/// Calculate the starting offset for expression tags
61-
const EXPR_TAG_START = blk: {
62-
// Get the maximum value from StmtTag enum
63-
var max: u8 = 0;
64-
for (std.meta.fields(StmtTag)) |field| {
65-
if (field.value > max) {
66-
max = @intCast(field.value);
67-
}
68-
}
69-
// Expression tags start after the highest statement tag
70-
break :blk max + 1;
71-
};
61+
/// We start at 100 to avoid collision with AST2.Node.Tag values (which go up to ~68)
62+
const EXPR_TAG_START = 100;
7263

7364
/// CIR Expression tags - start after statement tags
7465
pub const ExprTag = enum(u8) {
@@ -123,17 +114,8 @@ pub const ExprTag = enum(u8) {
123114
};
124115

125116
/// Calculate the starting offset for pattern tags
126-
const PATT_TAG_START = blk: {
127-
// Get the maximum value from ExprTag enum
128-
var max: u8 = 0;
129-
for (std.meta.fields(ExprTag)) |field| {
130-
if (field.value > max) {
131-
max = @intCast(field.value);
132-
}
133-
}
134-
// Pattern tags start after the highest expression tag
135-
break :blk max + 1;
136-
};
117+
/// We start at 150 (EXPR_TAG_START=100 + ~48 ExprTag values + buffer)
118+
const PATT_TAG_START = 150;
137119

138120
/// CIR Pattern tags - start after expression tags
139121
pub const PattTag = enum(u8) {
@@ -355,7 +337,8 @@ pub fn getNodeTagPtr(self: *CIR, idx: AST2.Node.Idx) *AST2.Node.Tag {
355337

356338
/// Get an immutable node
357339
pub fn getNode(self: *const CIR, idx: AST2.Node.Idx) AST2.Node {
358-
return self.ast.*.nodes.get(@enumFromInt(@intFromEnum(idx)));
340+
const node = self.ast.*.nodes.get(@enumFromInt(@intFromEnum(idx)));
341+
return node;
359342
}
360343

361344
/// Mutate a node's tag in place to a CIR statement tag
@@ -974,6 +957,18 @@ fn canonicalizeLambdaParams(self: *CIR, allocator: Allocator, node_idx: AST2.Nod
974957
try self.scope_state.addIdent(allocator, node.payload.ident, patt_idx);
975958
try self.scope_state.recordVarPattern(allocator, patt_idx);
976959
},
960+
.tuple_literal => {
961+
// Multiple parameters passed as a tuple: |a, b| -> parsed as tuple_literal(a, b)
962+
// Iterate through each element and canonicalize as a parameter
963+
const nodes_idx = node.payload.nodes;
964+
if (!nodes_idx.isNil()) {
965+
var iter = self.ast.*.node_slices.nodes(&nodes_idx);
966+
while (iter.next()) |param_node| {
967+
try self.canonicalizeLambdaParams(allocator, param_node, raw_src, idents);
968+
}
969+
}
970+
// Don't mutate the tuple_literal node itself - it's just a container for params
971+
},
977972
.binop_pipe => {
978973
// Multiple parameters: |a| b | rest
979974
// This is nested binop_pipe for multiple parameters
@@ -2583,7 +2578,7 @@ test "CIR2 error: expression in statement context" {
25832578
defer byte_slices.entries.deinit(allocator);
25842579

25852580
// Create a number literal node (expression)
2586-
const node_idx = try ast_ptr.appendNode(allocator, Position{ .offset = 0 }, .num_literal_i32, .{ .num_literal_i32 = 42 });
2581+
const node_idx = try ast_ptr.appendNode(allocator, Region{ .start = Position{ .offset = 0 }, .end = Position{ .offset = 2 } }, .num_literal_i32, .{ .num_literal_i32 = 42 });
25872582

25882583
// Create a TypeStore for testing
25892584
var types_store = try TypeStore.initCapacity(allocator, 100, 10);
@@ -2632,7 +2627,7 @@ test "CIR2 demonstrates in-place tag mutation" {
26322627

26332628
// Create an identifier node
26342629
const ident_idx = Ident.Idx{ .attributes = .{ .effectful = false, .ignored = false, .reassignable = false }, .idx = 1 };
2635-
const node_idx = try ast_ptr.appendNode(allocator, Position{ .offset = 0 }, .lc, .{ .ident = ident_idx });
2630+
const node_idx = try ast_ptr.appendNode(allocator, Region{ .start = Position{ .offset = 0 }, .end = Position{ .offset = 3 } }, .lc, .{ .ident = ident_idx });
26362631

26372632
// Verify initial AST tag
26382633
const initial_node = ast_ptr.nodes.get(@enumFromInt(@intFromEnum(node_idx)));
@@ -2734,9 +2729,9 @@ test "sign bit encoding: mutable vs immutable pattern canonicalization" {
27342729
// Create two identifier nodes
27352730
const ident_idx = Ident.Idx{ .attributes = .{ .effectful = false, .ignored = false, .reassignable = false }, .idx = 1 };
27362731

2737-
const node1_idx = try ast.appendNode(allocator, Position{ .offset = 0 }, .lc, .{ .ident = ident_idx });
2732+
const node1_idx = try ast.appendNode(allocator, Region{ .start = Position{ .offset = 0 }, .end = Position{ .offset = 3 } }, .lc, .{ .ident = ident_idx });
27382733

2739-
const node2_idx = try ast.appendNode(allocator, Position{ .offset = 10 }, .lc, .{ .ident = ident_idx });
2734+
const node2_idx = try ast.appendNode(allocator, Region{ .start = Position{ .offset = 10 }, .end = Position{ .offset = 13 } }, .lc, .{ .ident = ident_idx });
27402735

27412736
// Canonicalize one as immutable, one as mutable
27422737
const immutable_patt = try cir.canonicalizePatt(allocator, node1_idx);

0 commit comments

Comments
 (0)