From 799dada6a08428e8d3e4508874dceec6bdcaa814 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 4 Dec 2025 01:45:48 -0500 Subject: [PATCH] Delete a ton of unused arguments --- build.zig | 34 +++++++++++++- src/base/SExprTree.zig | 2 + src/base/safe_memory.zig | 2 + src/base58/mod.zig | 2 + src/build/glibc_stub.zig | 2 + src/build/tracy.zig | 1 + src/builtins/fuzz_sort.zig | 7 ++- src/builtins/list.zig | 2 + src/builtins/sort.zig | 2 + src/builtins/str.zig | 2 + src/builtins/utils.zig | 20 +++------ src/bundle/mod.zig | 1 - src/canonicalize/CIR.zig | 5 ++- src/canonicalize/Can.zig | 44 +++++++------------ src/canonicalize/Diagnostic.zig | 5 --- src/canonicalize/Expression.zig | 2 + src/canonicalize/ExternalDecl.zig | 6 +-- src/canonicalize/HostedCompiler.zig | 6 +-- src/canonicalize/ModuleEnv.zig | 20 ++------- src/canonicalize/NodeStore.zig | 11 ++--- src/canonicalize/test/frac_test.zig | 7 +-- src/check/Check.zig | 38 +++------------- src/check/problem.zig | 9 ++-- src/check/unify.zig | 3 ++ src/cli/main.zig | 5 ++- src/cli/test_docs.zig | 10 ----- src/collections/SortedArrayBuilder.zig | 2 + src/collections/safe_list.zig | 2 + src/compile/cache_key.zig | 9 ++-- src/compile/cache_manager.zig | 5 ++- src/compile/cache_module.zig | 5 ++- src/compile/compile_build.zig | 24 +++------- src/compile/compile_package.zig | 4 +- src/compile/test/module_env_test.zig | 3 -- src/eval/StackValue.zig | 2 + src/eval/comptime_evaluator.zig | 2 + src/eval/interpreter.zig | 2 + src/eval/test/TestEnv.zig | 2 + src/eval/test/comptime_eval_test.zig | 3 ++ .../test/interpreter_polymorphism_test.zig | 2 + src/eval/test/low_level_interp_test.zig | 2 + src/eval/test_runner.zig | 2 + src/fs/Filesystem.zig | 2 + src/ipc/SharedMemoryAllocator.zig | 2 + src/layout/store.zig | 20 ++------- src/lsp/handlers/shutdown.zig | 2 + src/lsp/syntax.zig | 5 ++- src/parse/AST.zig | 18 ++++---- src/parse/tokenize.zig | 5 ++- src/playground_wasm/WasmFilesystem.zig | 2 + src/playground_wasm/main.zig | 2 + src/repl/repl_test_env.zig | 6 +-- src/snapshot_tool/main.zig | 9 ++-- src/types/generalize.zig | 2 + src/types/store.zig | 5 ++- src/unbundle/test_unbundle.zig | 14 +++--- src/unbundle/unbundle.zig | 13 +++--- src/watch/watch.zig | 2 + 58 files changed, 200 insertions(+), 228 deletions(-) diff --git a/build.zig b/build.zig index 4758988627..ea04bba09e 100644 --- a/build.zig +++ b/build.zig @@ -334,7 +334,7 @@ const CheckUnusedSuppressionStep = struct { std.debug.print("=" ** 80 ++ "\n\n", .{}); std.debug.print( - \\In this codebase, we do NOT use `_ = variable;` to suppress unused variable warnings. + \\In this codebase, we do NOT use `_ = variable;` or `_:` to suppress unused warnings. \\ \\Instead, you should: \\ 1. Delete the unused variable, parameter, or argument @@ -359,7 +359,7 @@ const CheckUnusedSuppressionStep = struct { std.debug.print("\n" ++ "=" ** 80 ++ "\n", .{}); return step.fail( - "Found {d} unused variable suppression patterns (`_ = identifier;`). " ++ + "Found {d} unused variable/argument suppression patterns (`_ = identifier;` or `_:`). " ++ "Delete the unused variables/arguments and update call sites instead.", .{violations.items.len}, ); @@ -393,6 +393,12 @@ const CheckUnusedSuppressionStep = struct { const content = file.readToEndAlloc(allocator, 10 * 1024 * 1024) catch continue; defer allocator.free(content); + // Skip files that contain "// zig-lint: required-param" comment + // These are files with implementations that must match external API signatures + if (std.mem.indexOf(u8, content, "// zig-lint: required-param")) |_| { + continue; + } + var line_number: usize = 1; var line_start: usize = 0; @@ -410,6 +416,14 @@ const CheckUnusedSuppressionStep = struct { .line_content = try allocator.dupe(u8, trimmed), }); } + // Also check for _: pattern (unused argument in parameter list) + if (hasUnusedArgumentPattern(trimmed)) { + try violations.append(allocator, .{ + .file_path = full_path, + .line_number = line_number, + .line_content = try allocator.dupe(u8, trimmed), + }); + } line_number += 1; line_start = i + 1; @@ -440,6 +454,22 @@ const CheckUnusedSuppressionStep = struct { return true; } + + fn hasUnusedArgumentPattern(line: []const u8) bool { + // Pattern: `_:` in function parameter positions + // This catches patterns like `fn foo(_: SomeType)` or `_: anytype` + // We look for `_:` followed by a space and a type, or just `_:` with a type + var i: usize = 0; + while (i + 1 < line.len) : (i += 1) { + if (line[i] == '_' and line[i + 1] == ':') { + // Check that this is preceded by start of line, space, paren, or comma + if (i == 0 or line[i - 1] == ' ' or line[i - 1] == '(' or line[i - 1] == ',') { + return true; + } + } + } + return false; + } }; fn checkFxPlatformTestCoverage(step: *Step) !void { diff --git a/src/base/SExprTree.zig b/src/base/SExprTree.zig index d40cfb8197..486940e574 100644 --- a/src/base/SExprTree.zig +++ b/src/base/SExprTree.zig @@ -1,4 +1,6 @@ //! A S-expression tree representation +//! +// zig-lint: required-param const std = @import("std"); const testing = std.testing; diff --git a/src/base/safe_memory.zig b/src/base/safe_memory.zig index 8623dec262..e8d9df3282 100644 --- a/src/base/safe_memory.zig +++ b/src/base/safe_memory.zig @@ -1,5 +1,7 @@ //! Memory safety utilities for bounds checking and safe memory operations //! Provides helpers to prevent buffer overflows and memory corruption +//! +// zig-lint: required-param const std = @import("std"); diff --git a/src/base58/mod.zig b/src/base58/mod.zig index 05ee8ad3c7..cd3512d80f 100644 --- a/src/base58/mod.zig +++ b/src/base58/mod.zig @@ -1,5 +1,7 @@ //! Base58 encoding and decoding for BLAKE3 hashes //! +// zig-lint: required-param +//! //! This module provides base58 encoding/decoding specifically optimized for 256-bit BLAKE3 hashes. //! The base58 alphabet excludes visually similar characters (0, O, I, l) to prevent confusion. //! diff --git a/src/build/glibc_stub.zig b/src/build/glibc_stub.zig index 754f49b0f7..9c648c82a8 100644 --- a/src/build/glibc_stub.zig +++ b/src/build/glibc_stub.zig @@ -1,4 +1,6 @@ //! GNU libc stub generation for test platforms +//! +// zig-lint: required-param const std = @import("std"); diff --git a/src/build/tracy.zig b/src/build/tracy.zig index f279190f21..81a545af48 100644 --- a/src/build/tracy.zig +++ b/src/build/tracy.zig @@ -5,6 +5,7 @@ //! This file is part of zig, which is MIT licensed. //! See http://opensource.org/licenses/MIT //! +// zig-lint: required-param const std = @import("std"); const builtin = @import("builtin"); diff --git a/src/builtins/fuzz_sort.zig b/src/builtins/fuzz_sort.zig index 037b796b19..80b62be4f1 100644 --- a/src/builtins/fuzz_sort.zig +++ b/src/builtins/fuzz_sort.zig @@ -3,6 +3,8 @@ //! This module provides a fuzz testing implementation for sorting functions, //! featuring memory allocation tracking, sorting verification, and reference-counted //! comparison mechanisms. +//! +// zig-lint: required-param const std = @import("std"); const sort = @import("sort.zig"); @@ -97,9 +99,6 @@ fn testing_roc_dealloc(c_ptr: *anyopaque, _: u32) callconv(.c) void { allocator.free(slice); } -fn testing_roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.c) void { - _ = c_ptr; - _ = tag_id; - +fn testing_roc_panic(_: *anyopaque, _: u32) callconv(.c) void { @panic("Roc panicked"); } diff --git a/src/builtins/list.zig b/src/builtins/list.zig index c89e28294d..74493c0861 100644 --- a/src/builtins/list.zig +++ b/src/builtins/list.zig @@ -3,6 +3,8 @@ //! Lists use copy-on-write semantics to minimize allocations when shared across contexts. //! Seamless slice optimization reduces memory overhead for substring operations. //! +// zig-lint: required-param +//! //! ## Ownership Semantics //! //! See `OWNERSHIP.md` for the canonical terminology. Functions in this module diff --git a/src/builtins/sort.zig b/src/builtins/sort.zig index 9548221b15..8f6274cc8d 100644 --- a/src/builtins/sort.zig +++ b/src/builtins/sort.zig @@ -3,6 +3,8 @@ //! This module provides efficient sorting implementations for Roc's List type, //! including comparison-based sorting with custom compare functions. It handles //! both direct sorting for small lists and indirect pointer-based sorting for +//! +// zig-lint: required-param //! larger lists to optimize memory usage and cache performance. const std = @import("std"); diff --git a/src/builtins/str.zig b/src/builtins/str.zig index 0b2f8f7ab2..238b7f9297 100644 --- a/src/builtins/str.zig +++ b/src/builtins/str.zig @@ -3,6 +3,8 @@ //! This module provides the core implementation of Roc's Str type, including //! operations for string manipulation, Unicode handling, formatting, and //! memory management. It defines the RocStr structure and associated functions +//! +// zig-lint: required-param //! that are called from compiled Roc code to handle string operations efficiently. //! //! ## Ownership Semantics diff --git a/src/builtins/utils.zig b/src/builtins/utils.zig index f910b07fe4..4311408449 100644 --- a/src/builtins/utils.zig +++ b/src/builtins/utils.zig @@ -3,6 +3,8 @@ //! This module provides essential infrastructure for builtin operations, //! including memory allocation interfaces, overflow detection utilities, //! debug functions, and common types used throughout the builtin modules. +//! +// zig-lint: required-param //! It serves as the foundation layer that other builtin modules depend on //! for low-level operations and host interface functions. const std = @import("std"); @@ -163,18 +165,11 @@ pub const TestEnv = struct { } } - fn rocDbgFn(roc_dbg: *const RocDbg, env: *anyopaque) callconv(.c) void { - _ = env; - _ = roc_dbg; - } + fn rocDbgFn(_: *const RocDbg, _: *anyopaque) callconv(.c) void {} - fn rocExpectFailedFn(roc_expect: *const RocExpectFailed, env: *anyopaque) callconv(.c) void { - _ = env; - _ = roc_expect; - } + fn rocExpectFailedFn(_: *const RocExpectFailed, _: *anyopaque) callconv(.c) void {} - fn rocCrashedFn(roc_crashed: *const RocCrashed, env: *anyopaque) callconv(.c) noreturn { - _ = env; + fn rocCrashedFn(roc_crashed: *const RocCrashed, _: *anyopaque) callconv(.c) noreturn { const message = roc_crashed.utf8_bytes[0..roc_crashed.len]; @panic(message); } @@ -763,10 +758,9 @@ test "TestEnv basic functionality" { // Should start with no allocations try std.testing.expectEqual(@as(usize, 0), test_env.getAllocationCount()); - // Get ops should work + // Get ops should work - verify we can get ops and it points back to our test env const ops = test_env.getOps(); - // Function pointers are non-null by design, just verify we can get ops - _ = ops; + try std.testing.expectEqual(@as(*anyopaque, @ptrCast(&test_env)), ops.env); } test "TestEnv allocation tracking" { diff --git a/src/bundle/mod.zig b/src/bundle/mod.zig index be0a727270..60d66563ca 100644 --- a/src/bundle/mod.zig +++ b/src/bundle/mod.zig @@ -40,5 +40,4 @@ pub const freeForZstd = bundle.freeForZstd; test { _ = @import("test_bundle.zig"); _ = @import("test_streaming.zig"); - _ = bundle; } diff --git a/src/canonicalize/CIR.zig b/src/canonicalize/CIR.zig index 332966cf4f..a218d71225 100644 --- a/src/canonicalize/CIR.zig +++ b/src/canonicalize/CIR.zig @@ -1,5 +1,7 @@ //! Common IR types and utilities //! This module contains type definitions and utilities used across the canonicalization IR. +//! +// zig-lint: required-param const std = @import("std"); const types_mod = @import("types"); @@ -271,7 +273,7 @@ pub const WhereClause = union(enum) { const attrs = tree.beginNode(); try tree.endNode(begin, attrs); }, - .w_malformed => |malformed| { + .w_malformed => { const begin = tree.beginNode(); try tree.pushStaticAtom("malformed"); @@ -280,7 +282,6 @@ pub const WhereClause = union(enum) { const region = cir.store.getRegionAt(node_idx); try cir.appendRegionInfoToSExprTreeFromRegion(tree, region); - _ = malformed; const attrs = tree.beginNode(); try tree.endNode(begin, attrs); }, diff --git a/src/canonicalize/Can.zig b/src/canonicalize/Can.zig index 80616febdb..aabb358448 100644 --- a/src/canonicalize/Can.zig +++ b/src/canonicalize/Can.zig @@ -1,5 +1,7 @@ //! Transforms Abstract Syntax Tree (AST) into Canonical Intermediate Representation (CIR) through desugaring and scope resolution. //! +// zig-lint: required-param +//! //! This module performs semantic analysis, resolves scoping, and transforms high-level language //! constructs into a simplified, normalized form suitable for type inference. @@ -1322,10 +1324,8 @@ fn processAssociatedItemsSecondPass( fn registerUserFacingName( self: *Self, fully_qualified_idx: Ident.Idx, - item_name_idx: Ident.Idx, pattern_idx: CIR.Pattern.Idx, ) std.mem.Allocator.Error!void { - _ = item_name_idx; // Get the fully qualified text and strip the module prefix const fully_qualified_text = self.env.getIdent(fully_qualified_idx); @@ -1656,7 +1656,7 @@ fn processAssociatedItemsFirstPass( // - Module scope gets "Foo.Bar.baz" (user-facing fully qualified) // - Foo's scope gets "Bar.baz" (partially qualified) // - Bar's scope gets "baz" (unqualified) - try self.registerUserFacingName(qualified_idx, decl_ident, placeholder_pattern_idx); + try self.registerUserFacingName(qualified_idx, placeholder_pattern_idx); } } }, @@ -1684,7 +1684,7 @@ fn processAssociatedItemsFirstPass( try current_scope.idents.put(self.env.gpa, qualified_idx, placeholder_pattern_idx); // Register progressively qualified names at each scope level per the plan - try self.registerUserFacingName(qualified_idx, anno_ident, placeholder_pattern_idx); + try self.registerUserFacingName(qualified_idx, placeholder_pattern_idx); } }, else => { @@ -2280,9 +2280,8 @@ pub fn canonicalizeFile( } } }, - .malformed => |malformed| { + .malformed => { // We won't touch this since it's already a parse error. - _ = malformed; }, } } @@ -2687,9 +2686,8 @@ fn addToExposedScope( try self.exposed_type_texts.put(gpa, type_text, region); } }, - .malformed => |malformed| { + .malformed => { // Malformed exposed items are already captured as diagnostics during parsing - _ = malformed; }, } } @@ -2895,20 +2893,14 @@ fn bringImportIntoScope( const exposed = self.parse_ir.store.getExposedItem(exposed_idx); switch (exposed) { .lower_ident => |ident| { - // TODO handle `as` here using an Alias - - if (self.parse_ir.tokens.resolveIdentifier(ident.ident)) |ident_idx| { - _ = ident_idx; - - // TODO Introduce our import - + // TODO Introduce our import + if (self.parse_ir.tokens.resolveIdentifier(ident.ident)) |_| { // _ = self.scope.levels.introduce(gpa, &self.env.idents, .ident, .{ .scope_name = ident_idx, .ident = ident_idx }); } }, - .upper_ident => |imported_type| { - _ = imported_type; - // const alias = Alias{ + .upper_ident => { + // TODO: const alias = Alias{ // .name = imported_type.name, // .region = ir.env.tag_names.getRegion(imported_type.name), // .is_builtin = false, @@ -2921,9 +2913,7 @@ fn bringImportIntoScope( // .alias = alias_idx, // }); }, - .upper_ident_star => |ident| { - _ = ident; - }, + .upper_ident_star => {}, } } } @@ -5662,7 +5652,7 @@ pub fn canonicalizeExpr( }, .for_expr => |for_expr| { const region = self.parse_ir.tokenizedRegionToRegion(for_expr.region); - const result = try self.canonicalizeForLoop(for_expr.patt, for_expr.expr, for_expr.body, region); + const result = try self.canonicalizeForLoop(for_expr.patt, for_expr.expr, for_expr.body); const for_expr_idx = try self.env.addExpr(Expr{ .e_for = .{ @@ -5674,9 +5664,8 @@ pub fn canonicalizeExpr( return CanonicalizedExpr{ .idx = for_expr_idx, .free_vars = result.free_vars }; }, - .malformed => |malformed| { + .malformed => { // We won't touch this since it's already a parse error. - _ = malformed; return null; }, } @@ -5712,9 +5701,7 @@ fn canonicalizeForLoop( ast_patt: AST.Pattern.Idx, ast_list_expr: AST.Expr.Idx, ast_body: AST.Expr.Idx, - region: base.Region, ) std.mem.Allocator.Error!CanonicalizedForLoop { - _ = region; // Tmp state to capture free vars from both expr & body // This is stored as a map to avoid duplicate captures @@ -7179,9 +7166,8 @@ fn canonicalizePattern( return pattern_idx; } }, - .malformed => |malformed| { + .malformed => { // We won't touch this since it's already a parse error. - _ = malformed; return null; }, } @@ -9256,7 +9242,7 @@ pub fn canonicalizeBlockStatement(self: *Self, ast_stmt: AST.Statement, ast_stmt }, .@"for" => |for_stmt| { const region = self.parse_ir.tokenizedRegionToRegion(for_stmt.region); - const result = try self.canonicalizeForLoop(for_stmt.patt, for_stmt.expr, for_stmt.body, region); + const result = try self.canonicalizeForLoop(for_stmt.patt, for_stmt.expr, for_stmt.body); const stmt_idx = try self.env.addStatement(Statement{ .s_for = .{ diff --git a/src/canonicalize/Diagnostic.zig b/src/canonicalize/Diagnostic.zig index 3f52ed71bd..d6b65fbb6e 100644 --- a/src/canonicalize/Diagnostic.zig +++ b/src/canonicalize/Diagnostic.zig @@ -468,7 +468,6 @@ pub const Diagnostic = union(enum) { allocator: Allocator, ident_name: []const u8, region_info: base.RegionInfo, - original_region_info: base.RegionInfo, filename: []const u8, source: []const u8, line_starts: []const u32, @@ -490,10 +489,6 @@ pub const Diagnostic = union(enum) { line_starts, ); - // we don't need to display the original region info - // as this header is in a single location - _ = original_region_info; - try report.document.addReflowingText("You can remove the duplicate entry to fix this warning."); return report; diff --git a/src/canonicalize/Expression.zig b/src/canonicalize/Expression.zig index 8fca69e4d7..767acc6e77 100644 --- a/src/canonicalize/Expression.zig +++ b/src/canonicalize/Expression.zig @@ -1,5 +1,7 @@ //! Expression constructs used in Roc's canonicalization phase. //! +// zig-lint: required-param +//! //! This module defines the `Expr` union which represents all possible expressions //! in Roc's Canonical Intermediate Representation (CIR). These expressions are //! created during the canonicalization phase and represent the semantic meaning diff --git a/src/canonicalize/ExternalDecl.zig b/src/canonicalize/ExternalDecl.zig index 419db29acc..475c36ee20 100644 --- a/src/canonicalize/ExternalDecl.zig +++ b/src/canonicalize/ExternalDecl.zig @@ -1,4 +1,6 @@ //! Represents an external declaration from another module +//! +// zig-lint: required-param const base = @import("base"); const collections = @import("collections"); @@ -22,8 +24,6 @@ pub const Idx = enum(u32) { _ }; pub const Span = extern struct { span: DataSpan }; /// Converts this external declaration to an S-expression tree representation for debugging -pub fn pushToSExprTree(self: *const ExternalDecl, cir: anytype, tree: anytype) !void { - _ = self; - _ = cir; +pub fn pushToSExprTree(_: *const ExternalDecl, _: anytype, tree: anytype) !void { try tree.pushStaticAtom("external-decl-stub"); } diff --git a/src/canonicalize/HostedCompiler.zig b/src/canonicalize/HostedCompiler.zig index 5ee2096879..d18a4125b9 100644 --- a/src/canonicalize/HostedCompiler.zig +++ b/src/canonicalize/HostedCompiler.zig @@ -1,5 +1,7 @@ //! Compiler support for hosted functions in platform modules. //! +// zig-lint: required-param +//! //! This module handles the transformation of annotation-only declarations //! into hosted lambda expressions that will be provided by the platform at runtime. @@ -122,10 +124,6 @@ pub fn replaceAnnoOnlyWithHosted(env: *ModuleEnv) !std.ArrayList(CIR.Def.Idx) { env.store.extra_data.items.items[extra_start + 1] = @intFromEnum(expr_idx); - // Verify the def still has its annotation after modification - const modified_def = env.store.getDef(def_idx); - _ = modified_def; - // Track this modified def index try modified_def_indices.append(gpa, def_idx); } diff --git a/src/canonicalize/ModuleEnv.zig b/src/canonicalize/ModuleEnv.zig index 30a78b70e0..7a7055a7d3 100644 --- a/src/canonicalize/ModuleEnv.zig +++ b/src/canonicalize/ModuleEnv.zig @@ -981,7 +981,6 @@ pub fn diagnosticToReport(self: *Self, diagnostic: CIR.Diagnostic, allocator: st .redundant_exposed => |data| blk: { const ident_name = self.getIdent(data.ident); const region_info = self.calcRegionInfo(data.region); - const original_region_info = self.calcRegionInfo(data.original_region); var report = Report.init(allocator, "REDUNDANT EXPOSED", .warning); const owned_ident = try report.addOwnedString(ident_name); @@ -1000,10 +999,6 @@ pub fn diagnosticToReport(self: *Self, diagnostic: CIR.Diagnostic, allocator: st self.getLineStartsAll(), ); - // we don't need to display the original region info - // as this header is in a single location - _ = original_region_info; - try report.document.addReflowingText("You can remove the duplicate entry to fix this warning."); break :blk report; @@ -1205,9 +1200,7 @@ pub fn diagnosticToReport(self: *Self, diagnostic: CIR.Diagnostic, allocator: st break :blk report; }, - .lambda_body_not_canonicalized => |data| blk: { - _ = data; - + .lambda_body_not_canonicalized => blk: { var report = Report.init(allocator, "INVALID LAMBDA", .runtime_error); try report.document.addReflowingText("The body of this lambda expression is not valid."); @@ -1233,9 +1226,7 @@ pub fn diagnosticToReport(self: *Self, diagnostic: CIR.Diagnostic, allocator: st break :blk report; }, - .var_across_function_boundary => |data| blk: { - _ = data; - + .var_across_function_boundary => blk: { var report = Report.init(allocator, "VAR REASSIGNMENT ERROR", .runtime_error); try report.document.addReflowingText("Cannot reassign a "); try report.document.addKeyword("var"); @@ -1247,9 +1238,7 @@ pub fn diagnosticToReport(self: *Self, diagnostic: CIR.Diagnostic, allocator: st break :blk report; }, - .tuple_elem_not_canonicalized => |data| blk: { - _ = data; - + .tuple_elem_not_canonicalized => blk: { var report = Report.init(allocator, "INVALID TUPLE ELEMENT", .runtime_error); try report.document.addReflowingText("This tuple element is malformed or contains invalid syntax."); @@ -2237,8 +2226,7 @@ pub fn addMatchBranchPattern(self: *Self, expr: CIR.Expr.Match.BranchPattern, re /// Add a new pattern record field to the node store. /// This function asserts that the nodes and regions are in sync. -pub fn addPatternRecordField(self: *Self, expr: CIR.PatternRecordField, region: Region) std.mem.Allocator.Error!CIR.PatternRecordField.Idx { - _ = region; +pub fn addPatternRecordField(self: *Self, expr: CIR.PatternRecordField) std.mem.Allocator.Error!CIR.PatternRecordField.Idx { const expr_idx = try self.store.addPatternRecordField(expr); self.debugAssertArraysInSync(); return expr_idx; diff --git a/src/canonicalize/NodeStore.zig b/src/canonicalize/NodeStore.zig index 4bf4977844..1bb90f4916 100644 --- a/src/canonicalize/NodeStore.zig +++ b/src/canonicalize/NodeStore.zig @@ -1,4 +1,6 @@ //! Stores AST nodes and provides scratch arrays for working with nodes. +//! +// zig-lint: required-param const std = @import("std"); const base = @import("base"); @@ -1126,9 +1128,7 @@ pub fn getPattern(store: *const NodeStore, pattern_idx: CIR.Pattern.Idx) CIR.Pat } /// Retrieves a pattern record field from the store. -pub fn getPatternRecordField(store: *NodeStore, patternRecordField: CIR.PatternRecordField.Idx) CIR.PatternRecordField { - _ = store; - _ = patternRecordField; +pub fn getPatternRecordField(_: *NodeStore, _: CIR.PatternRecordField.Idx) CIR.PatternRecordField { // Return empty placeholder since PatternRecordField has no fields yet return CIR.PatternRecordField{}; } @@ -2140,10 +2140,7 @@ pub fn addPattern(store: *NodeStore, pattern: CIR.Pattern, region: base.Region) } /// Adds a pattern record field to the store. -pub fn addPatternRecordField(store: *NodeStore, patternRecordField: CIR.PatternRecordField) Allocator.Error!CIR.PatternRecordField.Idx { - _ = store; - _ = patternRecordField; - +pub fn addPatternRecordField(_: *NodeStore, _: CIR.PatternRecordField) Allocator.Error!CIR.PatternRecordField.Idx { return @enumFromInt(0); } diff --git a/src/canonicalize/test/frac_test.zig b/src/canonicalize/test/frac_test.zig index 3d2c03ca2c..d1f30a4ad3 100644 --- a/src/canonicalize/test/frac_test.zig +++ b/src/canonicalize/test/frac_test.zig @@ -30,9 +30,7 @@ test "fractional literal - basic decimal" { try testing.expectEqual(dec.value.numerator, 314); try testing.expectEqual(dec.value.denominator_power_of_ten, 2); }, - .e_dec => |dec| { - _ = dec; - }, + .e_dec => {}, else => { std.debug.print("Unexpected expr type: {}\n", .{expr}); try testing.expect(false); // Should be dec_small or frac_dec @@ -54,9 +52,8 @@ test "fractional literal - scientific notation small" { // This is expected behavior when the value is too small for i16 representation try testing.expectEqual(dec.value.numerator, 0); }, - .e_dec => |frac| { + .e_dec => { // RocDec stores the value in a special format - _ = frac; }, .e_frac_f64 => |frac| { try testing.expectApproxEqAbs(frac.value, 1.23e-10, 1e-20); diff --git a/src/check/Check.zig b/src/check/Check.zig index e38c00ac9c..7c95fc5ced 100644 --- a/src/check/Check.zig +++ b/src/check/Check.zig @@ -1,5 +1,7 @@ //! Performs Hindley-Milner type inference with constraint solving and unification on the Canonical Intermediate Representation (CIR). //! +// zig-lint: required-param +//! //! This module implements constraint-based type inference. const std = @import("std"); @@ -1497,8 +1499,7 @@ fn generateStaticDispatchConstraintFromWhere(self: *Self, where_idx: CIR.WhereCl }, }); }, - .w_alias => |alias| { - _ = alias; + .w_alias => { // TODO: Recursively unwrap alias }, .w_malformed => { @@ -4964,28 +4965,6 @@ fn handleRecursiveConstraint( /// /// Initially, we only have to check constraint for `Test.to_str2`. But when we /// process that, we then have to check `Test.to_str`. -/// Check a from_numeral constraint - actual validation happens during comptime evaluation -fn checkNumeralConstraint( - self: *Self, - type_var: Var, - constraint: types_mod.StaticDispatchConstraint, - num_lit_info: types_mod.NumeralInfo, - nominal_type: types_mod.NominalType, - env: *Env, -) !void { - // Mark parameters as intentionally unused - validation happens in comptime evaluation - _ = self; - _ = type_var; - _ = constraint; - _ = num_lit_info; - _ = nominal_type; - _ = env; - - // All numeric literal validation now happens during comptime evaluation - // in ComptimeEvaluator.validateDeferredNumericLiterals() - // This function exists only to satisfy the constraint checking interface -} - fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Allocator.Error!void { var deferred_constraint_len = env.deferred_static_dispatch_constraints.items.items.len; var deferred_constraint_index: usize = 0; @@ -5250,16 +5229,9 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca if (any_arg_failed or ret_result.isProblem()) { try self.unifyWith(deferred_constraint.var_, .err, env); try self.unifyWith(resolved_func.ret, .err, env); - } else if (constraint.origin == .from_numeral and constraint.num_literal != null) { - // For from_numeral constraints on builtin types, do compile-time validation - try self.checkNumeralConstraint( - deferred_constraint.var_, - constraint, - constraint.num_literal.?, - nominal_type, - env, - ); } + // Note: from_numeral constraint validation happens during comptime evaluation + // in ComptimeEvaluator.validateDeferredNumericLiterals() } } else if (dispatcher_content == .structure and (dispatcher_content.structure == .record or diff --git a/src/check/problem.zig b/src/check/problem.zig index ab32217849..7912deb868 100644 --- a/src/check/problem.zig +++ b/src/check/problem.zig @@ -454,7 +454,7 @@ pub const ReportBuilder = struct { const expected_content = self.snapshots.getContent(types.expected_snapshot); const actual_content = self.snapshots.getContent(types.actual_snapshot); - if (types.from_annotation and self.areBothFunctionSnapshots(expected_content, actual_content)) { + if (types.from_annotation and areBothFunctionSnapshots(expected_content, actual_content)) { // When we have constraint_origin_var, it indicates this error originated from // a specific constraint like a dot access (e.g., str.to_utf8()). // In this case, show a specialized argument type mismatch error. @@ -2436,13 +2436,12 @@ pub const ReportBuilder = struct { } /// Check if both snapshot contents represent function types - fn areBothFunctionSnapshots(self: *Self, expected_content: snapshot.SnapshotContent, actual_content: snapshot.SnapshotContent) bool { - return self.isSnapshotFunction(expected_content) and self.isSnapshotFunction(actual_content); + fn areBothFunctionSnapshots(expected_content: snapshot.SnapshotContent, actual_content: snapshot.SnapshotContent) bool { + return isSnapshotFunction(expected_content) and isSnapshotFunction(actual_content); } /// Check if a snapshot content represents a function type - fn isSnapshotFunction(self: *Self, content: snapshot.SnapshotContent) bool { - _ = self; + fn isSnapshotFunction(content: snapshot.SnapshotContent) bool { return switch (content) { .structure => |structure| switch (structure) { .fn_pure, .fn_effectful, .fn_unbound => true, diff --git a/src/check/unify.zig b/src/check/unify.zig index c5c2711203..489b468113 100644 --- a/src/check/unify.zig +++ b/src/check/unify.zig @@ -1,4 +1,7 @@ //! This module implements Hindley-Milner style type unification with extensions for: +//! +// zig-lint: required-param +//! //! * flex/rigid variables //! * type aliases //! * tuples diff --git a/src/cli/main.zig b/src/cli/main.zig index 4cf6aaa78e..ab4c159b89 100644 --- a/src/cli/main.zig +++ b/src/cli/main.zig @@ -1,6 +1,8 @@ //! Roc command line interface for the new compiler. Entrypoint of the Roc binary. //! Build with `zig build -Dfuzz -Dsystem-afl=false`. //! Result is at `./zig-out/bin/roc` +//! +// zig-lint: required-param const std = @import("std"); @@ -3217,8 +3219,7 @@ fn rocTest(allocs: *Allocators, args: cli_args.TestArgs) !void { } } -fn rocRepl(allocs: *Allocators) !void { - _ = allocs; +fn rocRepl(_: *Allocators) !void { const stderr = stderrWriter(); defer stderr.flush() catch {}; stderr.print("repl not implemented\n", .{}) catch {}; diff --git a/src/cli/test_docs.zig b/src/cli/test_docs.zig index 8492031131..2cca1198a4 100644 --- a/src/cli/test_docs.zig +++ b/src/cli/test_docs.zig @@ -86,13 +86,6 @@ test "roc docs generates nested package documentation" { \\ ); - // Create output directory path - const output_dir = try std.fs.path.join(gpa, &[_][]const u8{ tmp_path, "generated-docs" }); - defer gpa.free(output_dir); - - const root_path = try std.fs.path.join(gpa, &[_][]const u8{ tmp_path, "root.roc" }); - defer gpa.free(root_path); - // Note: We would call main.rocDocs(gpa, args) here, but it requires // a full build environment setup. Instead, we test the individual // helper functions in separate tests below. @@ -103,9 +96,6 @@ test "roc docs generates nested package documentation" { tmp.dir.access("bar/main.roc", .{}) catch unreachable; tmp.dir.access("baz/main.roc", .{}) catch unreachable; tmp.dir.access("qux/main.roc", .{}) catch unreachable; - - _ = root_path; - _ = output_dir; } test "generatePackageIndex creates valid HTML" { diff --git a/src/collections/SortedArrayBuilder.zig b/src/collections/SortedArrayBuilder.zig index abb0ef4c45..9787b77ede 100644 --- a/src/collections/SortedArrayBuilder.zig +++ b/src/collections/SortedArrayBuilder.zig @@ -1,5 +1,7 @@ //! A builder for creating sorted arrays with binary search lookups. //! +// zig-lint: required-param +//! //! SortedArrayBuilder provides a way to build key-value mappings that are //! optimized for small sizes and deterministic serialization. It maintains //! a sorted array internally, enabling efficient binary search lookups. diff --git a/src/collections/safe_list.zig b/src/collections/safe_list.zig index 8dd6abbf1a..b031aebc79 100644 --- a/src/collections/safe_list.zig +++ b/src/collections/safe_list.zig @@ -1,4 +1,6 @@ //! Lists that make it easier to avoid incorrect indexing. +//! +// zig-lint: required-param const std = @import("std"); diff --git a/src/compile/cache_key.zig b/src/compile/cache_key.zig index a1c9d6352a..89279a9376 100644 --- a/src/compile/cache_key.zig +++ b/src/compile/cache_key.zig @@ -1,4 +1,6 @@ //! Cache key generation and management for uniquely identifying cached compilation results. +//! +// zig-lint: required-param const std = @import("std"); const fs_mod = @import("fs"); @@ -84,13 +86,10 @@ pub const CacheKey = struct { /// Format cache key for debugging output. pub fn format( self: Self, - comptime fmt: []const u8, - options: std.fmt.FormatOptions, + comptime _: []const u8, + _: std.fmt.FormatOptions, writer: anytype, ) !void { - _ = fmt; - _ = options; - try writer.print("CacheKey{{ content: {x}, mtime: {}, compiler: {x} }}", .{ self.content_hash[0..8], // First 8 bytes for readability self.file_mtime, diff --git a/src/compile/cache_manager.zig b/src/compile/cache_manager.zig index 1cab65ecb6..2aa4efb631 100644 --- a/src/compile/cache_manager.zig +++ b/src/compile/cache_manager.zig @@ -1,4 +1,6 @@ //! Modern cache manager that uses BLAKE3-based keys and subdirectory splitting. +//! +// zig-lint: required-param const std = @import("std"); const base = @import("base"); @@ -66,8 +68,7 @@ pub const CacheManager = struct { } /// Deinitialize the cache manager. - pub fn deinit(self: *Self) void { - _ = self; + pub fn deinit(_: *Self) void { // Nothing to deinit currently } diff --git a/src/compile/cache_module.zig b/src/compile/cache_module.zig index 3466f8e5a9..8674e37fae 100644 --- a/src/compile/cache_module.zig +++ b/src/compile/cache_module.zig @@ -2,6 +2,8 @@ //! //! This module provides memory-mapped caching for compiled Roc modules, //! allowing fast serialization and deserialization of ModuleEnv and CIR data. +//! +// zig-lint: required-param const std = @import("std"); const Can = @import("can"); @@ -203,12 +205,11 @@ pub const CacheModule = struct { /// Convenience functions for reading/writing cache files pub fn writeToFile( - allocator: Allocator, + _: Allocator, cache_data: []const u8, file_path: []const u8, filesystem: anytype, ) !void { - _ = allocator; try filesystem.writeFile(file_path, cache_data); } diff --git a/src/compile/compile_build.zig b/src/compile/compile_build.zig index f559699fd7..97e50415e0 100644 --- a/src/compile/compile_build.zig +++ b/src/compile/compile_build.zig @@ -2,6 +2,8 @@ //! //! Modules are built in parallel unless targeting WebAssembly, which doesn't support threads. //! +// zig-lint: required-param +//! //! Errors are reported as soon as they're encountered, with the only exception being that //! there is some buffering to make their output order determined by the dependency graph //! rather than by parallelism races. In other words, if you build the same set of source files @@ -294,10 +296,8 @@ const GlobalQueue = struct { } // Hook from ModuleBuild to enqueue newly discovered/scheduled modules - pub fn hookOnSchedule(ctx: ?*anyopaque, package_name: []const u8, module_name: []const u8, _path: []const u8, _depth: u32) void { + pub fn hookOnSchedule(ctx: ?*anyopaque, package_name: []const u8, module_name: []const u8, _: []const u8, _: u32) void { var self: *GlobalQueue = @ptrCast(@alignCast(ctx.?)); - _ = _path; - _ = _depth; // Enqueue to global queue - log but don't fail on error self.enqueue(package_name, module_name) catch { // Continue anyway - the module will still be processed by local scheduler @@ -682,14 +682,8 @@ pub const BuildEnv = struct { ws: *BuildEnv, // Called by ModuleBuild.schedule_hook when a module is discovered/scheduled - pub fn onSchedule(ctx: ?*anyopaque, package_name: []const u8, module_name: []const u8, _path: []const u8, _depth: u32) void { - const self: *ScheduleCtx = @ptrCast(@alignCast(ctx.?)); - _ = package_name; - _ = module_name; - _ = _path; - _ = _depth; + pub fn onSchedule(_: ?*anyopaque, _: []const u8, _: []const u8, _: []const u8, _: u32) void { // Early reports auto-register in OrderedSink.emitReport when they are emitted - _ = self; } }; @@ -704,12 +698,6 @@ pub const BuildEnv = struct { } } - fn resolverClassify(ctx: ?*anyopaque, _: []const u8, _: []const u8) bool { - _ = ctx; - // Unused: ModuleBuild determines external vs local from CIR (s_import.qualifier_tok) - return false; - } - fn resolverScheduleExternal(ctx: ?*anyopaque, current_package: []const u8, import_name: []const u8) void { var self: *ResolverCtx = @ptrCast(@alignCast(ctx.?)); const cur_pkg = self.ws.packages.get(current_package) orelse return; @@ -761,8 +749,7 @@ pub const BuildEnv = struct { return sched.*.getEnvIfDone(rest); } - fn resolverResolveLocalPath(ctx: ?*anyopaque, _current_package: []const u8, root_dir: []const u8, import_name: []const u8) []const u8 { - _ = _current_package; + fn resolverResolveLocalPath(ctx: ?*anyopaque, _: []const u8, root_dir: []const u8, import_name: []const u8) []const u8 { var self: *ResolverCtx = @ptrCast(@alignCast(ctx.?)); return self.ws.dottedToPath(root_dir, import_name) catch import_name; } @@ -774,7 +761,6 @@ pub const BuildEnv = struct { ctx.* = .{ .ws = self }; return .{ .ctx = ctx, - .classify = resolverClassify, .scheduleExternal = resolverScheduleExternal, .isReady = resolverIsReady, .getEnv = resolverGetEnv, diff --git a/src/compile/compile_package.zig b/src/compile/compile_package.zig index 90ff7775ee..7466e3d8d2 100644 --- a/src/compile/compile_package.zig +++ b/src/compile/compile_package.zig @@ -3,6 +3,8 @@ //! This component manages the concurrent compilation of all modules within a single package, //! orchestrating the build phases for each module: //! +// zig-lint: required-param +//! //! - Parsing modules to discover their import dependencies //! - Canonicalizing parsed modules into an intermediate representation //! - Type-checking modules once their dependencies are ready @@ -83,8 +85,6 @@ pub const ScheduleHook = struct { /// Resolver for handling imports across package boundaries pub const ImportResolver = struct { ctx: ?*anyopaque, - /// Return true if the import_name refers to an external package (e.g. "cli.Stdout") - classify: *const fn (ctx: ?*anyopaque, current_package: []const u8, import_name: []const u8) bool, /// Ensure the external import is scheduled for building in its owning package scheduleExternal: *const fn (ctx: ?*anyopaque, current_package: []const u8, import_name: []const u8) void, /// Return true if the external import is fully type-checked and its ModuleEnv is ready diff --git a/src/compile/test/module_env_test.zig b/src/compile/test/module_env_test.zig index c57a1872a5..b2c2bb3ff3 100644 --- a/src/compile/test/module_env_test.zig +++ b/src/compile/test/module_env_test.zig @@ -431,11 +431,8 @@ test "ModuleEnv pushExprTypesToSExprTree extracts and formats types" { .origin_module = builtin_ident, .is_opaque = false, }; - const str_type = try env.types.freshFromContent(.{ .structure = .{ .nominal_type = str_nominal } }); - // Add a string segment expression const segment_idx = try env.addExpr(.{ .e_str_segment = .{ .literal = str_literal_idx } }, base.Region.from_raw_offsets(0, 5)); - _ = str_type; // Now create a string expression that references the segment const expr_idx = try env.addExpr(.{ .e_str = .{ .span = Expr.Span{ .span = base.DataSpan{ .start = @intFromEnum(segment_idx), .len = 1 } } } }, base.Region.from_raw_offsets(0, 5)); diff --git a/src/eval/StackValue.zig b/src/eval/StackValue.zig index 1c65b0af7c..0c11b466d5 100644 --- a/src/eval/StackValue.zig +++ b/src/eval/StackValue.zig @@ -1,5 +1,7 @@ //! Represents a "value" on the Interpreter's stack. //! +// zig-lint: required-param +//! //! This is the public facing interface for interacting with stack values. //! //! It provides methods for working with the value safely using the layout. diff --git a/src/eval/comptime_evaluator.zig b/src/eval/comptime_evaluator.zig index 9f34364e59..beba94d3ba 100644 --- a/src/eval/comptime_evaluator.zig +++ b/src/eval/comptime_evaluator.zig @@ -2,6 +2,8 @@ //! //! This module evaluates all top-level declarations after type checking, //! converting any crashes into diagnostics that are reported normally. +//! +// zig-lint: required-param const std = @import("std"); const base = @import("base"); diff --git a/src/eval/interpreter.zig b/src/eval/interpreter.zig index e9655c5567..63b653d91b 100644 --- a/src/eval/interpreter.zig +++ b/src/eval/interpreter.zig @@ -1,4 +1,6 @@ //! Interpreter implementing the type-carrying architecture. +//! +// zig-lint: required-param const std = @import("std"); const builtin = @import("builtin"); diff --git a/src/eval/test/TestEnv.zig b/src/eval/test/TestEnv.zig index 8a223280d2..1f20c27ddd 100644 --- a/src/eval/test/TestEnv.zig +++ b/src/eval/test/TestEnv.zig @@ -1,4 +1,6 @@ //! An implementation of RocOps for testing purposes. +//! +// zig-lint: required-param const std = @import("std"); const builtins = @import("builtins"); diff --git a/src/eval/test/comptime_eval_test.zig b/src/eval/test/comptime_eval_test.zig index e8a022d9c5..3249bb0022 100644 --- a/src/eval/test/comptime_eval_test.zig +++ b/src/eval/test/comptime_eval_test.zig @@ -1,4 +1,7 @@ //! Tests for compile-time evaluation of top-level declarations +//! +// zig-lint: required-param + const std = @import("std"); const parse = @import("parse"); const types = @import("types"); diff --git a/src/eval/test/interpreter_polymorphism_test.zig b/src/eval/test/interpreter_polymorphism_test.zig index 1fac325e93..3a0e0ce9ce 100644 --- a/src/eval/test/interpreter_polymorphism_test.zig +++ b/src/eval/test/interpreter_polymorphism_test.zig @@ -1,6 +1,8 @@ //! Polymorphism tests for Interpreter focused on closures without captures (Milestone 1). //! Each test starts with Roc source (multiline Zig string with `\\`), parses + canonicalizes //! with early diagnostics, evaluates with Interpreter, and renders Roc output. +//! +// zig-lint: required-param const std = @import("std"); const helpers = @import("helpers.zig"); diff --git a/src/eval/test/low_level_interp_test.zig b/src/eval/test/low_level_interp_test.zig index 34d3043237..1baecf00e5 100644 --- a/src/eval/test/low_level_interp_test.zig +++ b/src/eval/test/low_level_interp_test.zig @@ -1,5 +1,7 @@ //! Tests for e_low_level_lambda runtime evaluation in the interpreter //! +// zig-lint: required-param +//! //! These tests verify that low-level operations (like Str.is_empty, List.concat) that are defined //! as e_low_level_lambda nodes correctly dispatch to their builtin implementations //! when called at compile-time, producing the correct runtime values. diff --git a/src/eval/test_runner.zig b/src/eval/test_runner.zig index 7574f59f0b..bf4cfe9ed5 100644 --- a/src/eval/test_runner.zig +++ b/src/eval/test_runner.zig @@ -1,6 +1,8 @@ //! Runs expect expressions //! //! This module is a wrapper around the interpreter used to simplify evaluating expect expressions. +//! +// zig-lint: required-param const std = @import("std"); const base = @import("base"); diff --git a/src/fs/Filesystem.zig b/src/fs/Filesystem.zig index 76c26a62b1..3a09c427cf 100644 --- a/src/fs/Filesystem.zig +++ b/src/fs/Filesystem.zig @@ -1,5 +1,7 @@ //! Abstract filesystem functions so we can mock them out for testing //! and also provide an alternative implementation for WASM (webREPL, playground). +//! +// zig-lint: required-param const std = @import("std"); const collections = @import("collections"); diff --git a/src/ipc/SharedMemoryAllocator.zig b/src/ipc/SharedMemoryAllocator.zig index f425a16a3c..d58f8cf906 100644 --- a/src/ipc/SharedMemoryAllocator.zig +++ b/src/ipc/SharedMemoryAllocator.zig @@ -8,6 +8,8 @@ //! resize it should never come up in practice, since coordinating resizing with the //! child process would be complex. //! +// zig-lint: required-param +//! //! ## Cross-platform coordination //! //! The allocator uses platform-specific coordination mechanisms: diff --git a/src/layout/store.zig b/src/layout/store.zig index 13eb2cf4db..96800c0203 100644 --- a/src/layout/store.zig +++ b/src/layout/store.zig @@ -1,4 +1,6 @@ //! Stores Layout values by index. +//! +// zig-lint: required-param const std = @import("std"); const builtin = @import("builtin"); @@ -1121,20 +1123,7 @@ pub const Store = struct { current = self.types_store.resolveVar(last_pending_field.var_); continue :outer; }, - .fn_pure => |func| { - _ = func; - // Create empty captures layout for generic function type - const empty_captures_idx = try self.getEmptyRecordLayout(); - break :flat_type Layout.closure(empty_captures_idx); - }, - .fn_effectful => |func| { - _ = func; - // Create empty captures layout for generic function type - const empty_captures_idx = try self.getEmptyRecordLayout(); - break :flat_type Layout.closure(empty_captures_idx); - }, - .fn_unbound => |func| { - _ = func; + .fn_pure, .fn_effectful, .fn_unbound => { // Create empty captures layout for generic function type const empty_captures_idx = try self.getEmptyRecordLayout(); break :flat_type Layout.closure(empty_captures_idx); @@ -1285,7 +1274,7 @@ pub const Store = struct { // and append our variant layouts. This ensures our variants are contiguous. const variants_start: u32 = @intCast(self.tag_union_variants.len()); - for (variant_layout_indices, 0..) |variant_layout_idx, variant_i| { + for (variant_layout_indices) |variant_layout_idx| { const variant_layout = self.getLayout(variant_layout_idx); const variant_size = self.layoutSize(variant_layout); const variant_alignment = variant_layout.alignment(self.targetUsize()); @@ -1298,7 +1287,6 @@ pub const Store = struct { _ = try self.tag_union_variants.append(self.env.gpa, .{ .payload_layout = variant_layout_idx, }); - _ = variant_i; } // Calculate discriminant info diff --git a/src/lsp/handlers/shutdown.zig b/src/lsp/handlers/shutdown.zig index b4a3b1925f..729b16d6a3 100644 --- a/src/lsp/handlers/shutdown.zig +++ b/src/lsp/handlers/shutdown.zig @@ -1,3 +1,5 @@ +// zig-lint: required-param + const std = @import("std"); const protocol = @import("../protocol.zig"); diff --git a/src/lsp/syntax.zig b/src/lsp/syntax.zig index 01ebe2d2bb..25b78e694b 100644 --- a/src/lsp/syntax.zig +++ b/src/lsp/syntax.zig @@ -1,5 +1,7 @@ //! Syntax checking integration that runs the Roc compiler and converts //! reports to LSP diagnostics. +//! +// zig-lint: required-param const std = @import("std"); const compile = @import("compile"); @@ -190,7 +192,7 @@ pub const SyntaxChecker = struct { }; } - fn rangeFromReport(self: *SyntaxChecker, rep: reporting.Report) Diagnostics.Range { + fn rangeFromReport(_: *SyntaxChecker, rep: reporting.Report) Diagnostics.Range { var start = Diagnostics.Position{ .line = 0, .character = 0 }; var end = Diagnostics.Position{ .line = 0, .character = 0 }; @@ -220,7 +222,6 @@ pub const SyntaxChecker = struct { } } - _ = self; return .{ .start = start, .end = end }; } diff --git a/src/parse/AST.zig b/src/parse/AST.zig index c6cf7e1730..45c05892bc 100644 --- a/src/parse/AST.zig +++ b/src/parse/AST.zig @@ -1000,7 +1000,7 @@ pub const Statement = union(enum) { try tree.pushStaticAtom("exposing"); const attrs2 = tree.beginNode(); for (ast.store.exposedItemSlice(import.exposes)) |e| { - try ast.store.getExposedItem(e).pushToSExprTree(gpa, env, ast, tree); + try ast.store.getExposedItem(e).pushToSExprTree(env, ast, tree); } try tree.endNode(exposed, attrs2); } @@ -1641,7 +1641,7 @@ pub const Header = union(enum) { // Could push region info for provides_coll here if desired for (provides_items) |item_idx| { const item = ast.store.getExposedItem(item_idx); - try item.pushToSExprTree(gpa, env, ast, tree); + try item.pushToSExprTree(env, ast, tree); } try tree.endNode(provides_begin, attrs2); @@ -1677,7 +1677,7 @@ pub const Header = union(enum) { const attrs2 = tree.beginNode(); for (ast.store.exposedItemSlice(.{ .span = exposes.span })) |exposed| { const item = ast.store.getExposedItem(exposed); - try item.pushToSExprTree(gpa, env, ast, tree); + try item.pushToSExprTree(env, ast, tree); } try tree.endNode(exposes_begin, attrs2); @@ -1697,7 +1697,7 @@ pub const Header = union(enum) { const attrs2 = tree.beginNode(); for (ast.store.exposedItemSlice(.{ .span = exposes.span })) |exposed| { const item = ast.store.getExposedItem(exposed); - try item.pushToSExprTree(gpa, env, ast, tree); + try item.pushToSExprTree(env, ast, tree); } try tree.endNode(exposes_begin, attrs2); @@ -1732,7 +1732,7 @@ pub const Header = union(enum) { // Could push region info for rigids here if desired for (ast.store.exposedItemSlice(.{ .span = rigids.span })) |exposed| { const item = ast.store.getExposedItem(exposed); - try item.pushToSExprTree(gpa, env, ast, tree); + try item.pushToSExprTree(env, ast, tree); } try tree.endNode(rigids_begin, attrs3); @@ -1748,7 +1748,7 @@ pub const Header = union(enum) { const attrs4 = tree.beginNode(); for (ast.store.exposedItemSlice(.{ .span = exposes.span })) |exposed| { const item = ast.store.getExposedItem(exposed); - try item.pushToSExprTree(gpa, env, ast, tree); + try item.pushToSExprTree(env, ast, tree); } try tree.endNode(exposes_begin, attrs4); @@ -1793,7 +1793,7 @@ pub const Header = union(enum) { const attrs2 = tree.beginNode(); for (ast.store.exposedItemSlice(.{ .span = exposes.span })) |exposed| { const item = ast.store.getExposedItem(exposed); - try item.pushToSExprTree(gpa, env, ast, tree); + try item.pushToSExprTree(env, ast, tree); } try tree.endNode(exposes_begin, attrs2); @@ -1866,9 +1866,7 @@ pub const ExposedItem = union(enum) { pub const Idx = enum(u32) { _ }; pub const Span = struct { span: base.DataSpan }; - pub fn pushToSExprTree(self: @This(), gpa: std.mem.Allocator, env: *const CommonEnv, ast: *const AST, tree: *SExprTree) std.mem.Allocator.Error!void { - _ = gpa; - + pub fn pushToSExprTree(self: @This(), env: *const CommonEnv, ast: *const AST, tree: *SExprTree) std.mem.Allocator.Error!void { switch (self) { .lower_ident => |i| { const begin = tree.beginNode(); diff --git a/src/parse/tokenize.zig b/src/parse/tokenize.zig index 9dee25192b..744ebc621b 100644 --- a/src/parse/tokenize.zig +++ b/src/parse/tokenize.zig @@ -1,5 +1,7 @@ //! Tokenization functionality for the Roc parser. //! +// zig-lint: required-param +//! //! This module provides the tokenizer that converts Roc source code into //! a stream of tokens for parsing. It handles all Roc language tokens including //! keywords, identifiers, literals, operators, and punctuation, representing @@ -1569,8 +1571,7 @@ pub const Tokenizer = struct { } /// Determines if a character can follow a unary minus (i.e., can start an expression) - fn canFollowUnaryMinus(self: *const Tokenizer, c: u8) bool { - _ = self; + fn canFollowUnaryMinus(_: *const Tokenizer, c: u8) bool { return switch (c) { // Identifiers 'a'...'z', 'A'...'Z', '_' => true, diff --git a/src/playground_wasm/WasmFilesystem.zig b/src/playground_wasm/WasmFilesystem.zig index bda8d3dc08..e28558ebf4 100644 --- a/src/playground_wasm/WasmFilesystem.zig +++ b/src/playground_wasm/WasmFilesystem.zig @@ -1,6 +1,8 @@ //! WASM-specific filesystem implementation for the playground. //! This provides a minimal filesystem interface where source code //! can be provided from JavaScript and most other operations return errors. +//! +// zig-lint: required-param const std = @import("std"); const fs_mod = @import("fs"); diff --git a/src/playground_wasm/main.zig b/src/playground_wasm/main.zig index feb3699be4..9f7790d4e4 100644 --- a/src/playground_wasm/main.zig +++ b/src/playground_wasm/main.zig @@ -2,6 +2,8 @@ //! //! This module provides a state machine interface for the Roc compiler. //! +// zig-lint: required-param +//! //! State Machine: //! 1. START: Initialize module, return compiler version //! 2. READY: Receive Roc source, compile through all stages, return "LOADED" with diagnostics diff --git a/src/repl/repl_test_env.zig b/src/repl/repl_test_env.zig index 90b2a4959a..6cb66aee8b 100644 --- a/src/repl/repl_test_env.zig +++ b/src/repl/repl_test_env.zig @@ -1,4 +1,6 @@ //! An implementation of RocOps for testing purposes. +//! +// zig-lint: required-param const std = @import("std"); const builtins = @import("builtins"); @@ -132,9 +134,7 @@ fn testRocRealloc(realloc_args: *RocRealloc, env: *anyopaque) callconv(.c) void realloc_args.answer = @ptrFromInt(@intFromPtr(new_slice.ptr) + size_storage_bytes); } -fn testRocDbg(dbg_args: *const RocDbg, env: *anyopaque) callconv(.c) void { - _ = dbg_args; - _ = env; +fn testRocDbg(_: *const RocDbg, _: *anyopaque) callconv(.c) void { @panic("testRocDbg not implemented yet"); } diff --git a/src/snapshot_tool/main.zig b/src/snapshot_tool/main.zig index 8b61f00142..2539014561 100644 --- a/src/snapshot_tool/main.zig +++ b/src/snapshot_tool/main.zig @@ -1,5 +1,7 @@ //! Snapshot testing infrastructure for the Roc compiler. //! +// zig-lint: required-param +//! //! This module provides functionality to generate and validate snapshot tests //! that capture the compiler's behavior at each stage of compilation. Snapshots //! help ensure the compiler continues to behave as expected by showing the @@ -2918,8 +2920,7 @@ fn generateReplOutputSection(output: *DualOutput, snapshot_path: []const u8, con return success; } -fn generateReplProblemsSection(output: *DualOutput, content: *const Content) !void { - _ = content; +fn generateReplProblemsSection(output: *DualOutput, _: *const Content) !void { try output.begin_section("PROBLEMS"); try output.md_writer.writer.writeAll("NIL\n"); @@ -3151,9 +3152,7 @@ fn snapshotRocRealloc(realloc_args: *RocRealloc, env: *anyopaque) callconv(.c) v realloc_args.answer = @ptrFromInt(@intFromPtr(new_slice.ptr) + size_storage_bytes); } -fn snapshotRocDbg(dbg_args: *const RocDbg, env: *anyopaque) callconv(.c) void { - _ = dbg_args; - _ = env; +fn snapshotRocDbg(_: *const RocDbg, _: *anyopaque) callconv(.c) void { @panic("snapshotRocDbg not implemented yet"); } diff --git a/src/types/generalize.zig b/src/types/generalize.zig index ae520abb2b..d2e152b438 100644 --- a/src/types/generalize.zig +++ b/src/types/generalize.zig @@ -1,5 +1,7 @@ //! Type generalization for Hindley-Milner type inference. //! +// zig-lint: required-param +//! //! This module implements the generalization phase of Hindley-Milner type inference, //! which determines which type variables can be made polymorphic (generalized). //! diff --git a/src/types/store.zig b/src/types/store.zig index 201550f4f5..583520c4df 100644 --- a/src/types/store.zig +++ b/src/types/store.zig @@ -1,5 +1,7 @@ //! The store of solved types //! Contains both Slot & Descriptor stores +//! +// zig-lint: required-param const std = @import("std"); const base = @import("base"); @@ -50,8 +52,7 @@ pub const Slot = union(enum) { redirect: Var, /// Calculate the size needed to serialize this Slot - pub fn serializedSize(self: *const Slot) usize { - _ = self; + pub fn serializedSize(_: *const Slot) usize { return @sizeOf(u8) + @sizeOf(u32); // tag + data } diff --git a/src/unbundle/test_unbundle.zig b/src/unbundle/test_unbundle.zig index 92dde64d22..dfec8b4c22 100644 --- a/src/unbundle/test_unbundle.zig +++ b/src/unbundle/test_unbundle.zig @@ -143,7 +143,7 @@ test "BufferExtractWriter - basic functionality" { // Create a file const file_writer = try writer.extractWriter().createFile("test.txt"); try file_writer.writeAll("Hello, World!"); - writer.extractWriter().finishFile(file_writer); + writer.extractWriter().finishFile(); // Create a directory (should be no-op for buffer writer) try writer.extractWriter().makeDir("test_dir"); @@ -151,7 +151,7 @@ test "BufferExtractWriter - basic functionality" { // Create another file in a subdirectory const file_writer2 = try writer.extractWriter().createFile("subdir/test2.txt"); try file_writer2.writeAll("Second file"); - writer.extractWriter().finishFile(file_writer2); + writer.extractWriter().finishFile(); // Verify files were stored try testing.expectEqual(@as(usize, 2), writer.files.count()); @@ -185,7 +185,7 @@ test "DirExtractWriter - basic functionality" { // Create a file const file_writer = try writer.extractWriter().createFile("test.txt"); try file_writer.writeAll("Test content"); - writer.extractWriter().finishFile(file_writer); + writer.extractWriter().finishFile(); // Verify file was created const content = try tmp.dir.readFileAlloc(testing.allocator, "test.txt", 1024); @@ -195,7 +195,7 @@ test "DirExtractWriter - basic functionality" { // Create a file in a subdirectory (should create parent dirs) const file_writer2 = try writer.extractWriter().createFile("deep/nested/file.txt"); try file_writer2.writeAll("Nested content"); - writer.extractWriter().finishFile(file_writer2); + writer.extractWriter().finishFile(); // Verify nested file was created const nested_content = try tmp.dir.readFileAlloc(testing.allocator, "deep/nested/file.txt", 1024); @@ -304,12 +304,12 @@ test "BufferExtractWriter - overwrite existing file" { // Create a file with initial content const file_writer1 = try writer.extractWriter().createFile("test.txt"); try file_writer1.writeAll("Initial content"); - writer.extractWriter().finishFile(file_writer1); + writer.extractWriter().finishFile(); // Overwrite the same file const file_writer2 = try writer.extractWriter().createFile("test.txt"); try file_writer2.writeAll("New content"); - writer.extractWriter().finishFile(file_writer2); + writer.extractWriter().finishFile(); // Verify it was overwritten const file = writer.files.get("test.txt"); @@ -327,7 +327,7 @@ test "DirExtractWriter - nested directory creation" { // Create a file in a deeply nested path const file_writer = try writer.extractWriter().createFile("a/b/c/d/e/file.txt"); try file_writer.writeAll("Nested content"); - writer.extractWriter().finishFile(file_writer); + writer.extractWriter().finishFile(); // Verify the file was created const content = try tmp.dir.readFileAlloc(testing.allocator, "a/b/c/d/e/file.txt", 1024); diff --git a/src/unbundle/unbundle.zig b/src/unbundle/unbundle.zig index ca477cd30a..46b3f83e36 100644 --- a/src/unbundle/unbundle.zig +++ b/src/unbundle/unbundle.zig @@ -65,7 +65,7 @@ pub const ExtractWriter = struct { pub const VTable = struct { createFile: *const fn (ptr: *anyopaque, path: []const u8) CreateFileError!*std.Io.Writer, - finishFile: *const fn (ptr: *anyopaque, writer: *std.Io.Writer) void, + finishFile: *const fn (ptr: *anyopaque) void, makeDir: *const fn (ptr: *anyopaque, path: []const u8) MakeDirError!void, }; @@ -82,8 +82,8 @@ pub const ExtractWriter = struct { return self.vtable.createFile(self.ptr, path); } - pub fn finishFile(self: ExtractWriter, writer: *std.Io.Writer) void { - return self.vtable.finishFile(self.ptr, writer); + pub fn finishFile(self: ExtractWriter) void { + return self.vtable.finishFile(self.ptr); } pub fn makeDir(self: ExtractWriter, path: []const u8) MakeDirError!void { @@ -162,8 +162,7 @@ pub const DirExtractWriter = struct { return &entry.writer.interface; } - fn finishFile(ptr: *anyopaque, writer: *std.Io.Writer) void { - _ = writer; + fn finishFile(ptr: *anyopaque) void { const self: *DirExtractWriter = @ptrCast(@alignCast(ptr)); // Close and remove the last file if (self.open_files.items.len > 0) { @@ -236,7 +235,7 @@ pub const BufferExtractWriter = struct { return &self.current_file_writer.?.writer; } - fn finishFile(ptr: *anyopaque, _: *std.Io.Writer) void { + fn finishFile(ptr: *anyopaque) void { const self: *BufferExtractWriter = @ptrCast(@alignCast(ptr)); if (self.current_file_writer) |*writer| { if (self.current_file_path) |path| { @@ -591,7 +590,7 @@ pub fn unbundleStream( }, .file => { const file_writer = try extract_writer.createFile(file_path); - defer extract_writer.finishFile(file_writer); + defer extract_writer.finishFile(); try tar_iterator.streamRemaining(entry, file_writer); try file_writer.flush(); diff --git a/src/watch/watch.zig b/src/watch/watch.zig index ce3a1f4a1b..db38d38290 100644 --- a/src/watch/watch.zig +++ b/src/watch/watch.zig @@ -1,5 +1,7 @@ //! File system watcher for monitoring .roc file changes across platforms. //! Provides efficient, cross-platform file watching with recursive directory support. +//! +// zig-lint: required-param const std = @import("std"); const builtin = @import("builtin");