From 0508a4984a45ba56c08a56ab1808c0aa80df19e3 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 10 Jul 2025 17:43:08 -0400 Subject: [PATCH] Fixes --- src/base/ModuleEnv.zig | 16 +- src/cache/CacheManager.zig | 15 +- src/cache/CacheModule.zig | 8 + src/check/canonicalize.zig | 51 +- .../test/exposed_shadowing_test.zig | 40 ++ src/check/canonicalize/test/frac_test.zig | 12 + .../test/import_validation_test.zig | 27 + src/check/canonicalize/test/int_test.zig | 4 + .../let_polymorphism_integration_test.zig | 12 + src/coordinate/ModuleGraph.zig | 4 + src/coordinate_simple.zig | 4 + src/fmt.zig | 8 + src/load/Builder.zig | 552 +++++++++--------- src/load/Task.zig | 12 - src/load/TestRunner.zig | 88 +-- src/load/test.zig | 4 +- src/main.zig | 190 +++--- src/snapshot.zig | 11 +- src/snapshots/can_import_exposing_types.md | 6 +- src/snapshots/can_import_type_annotations.md | 4 +- .../can_import_unresolved_qualified.md | 2 +- src/snapshots/can_list_rest_types.md | 2 +- src/snapshots/can_var_scoping_regular_var.md | 2 +- .../can_var_scoping_var_redeclaration.md | 2 +- src/snapshots/crash_and_ellipsis_test.md | 6 +- src/snapshots/expr/block_pattern_unify.md | 2 +- src/snapshots/expr/tuple_comprehensive.md | 14 +- src/snapshots/fuzz_crash/fuzz_crash_019.md | 14 +- src/snapshots/fuzz_crash/fuzz_crash_020.md | 14 +- src/snapshots/fuzz_crash/fuzz_crash_022.md | 2 +- src/snapshots/fuzz_crash/fuzz_crash_023.md | 28 +- src/snapshots/fuzz_crash/fuzz_crash_027.md | 28 +- src/snapshots/fuzz_crash/fuzz_crash_028.md | Bin 69209 -> 68728 bytes src/snapshots/hello_world_with_block.md | 2 +- src/snapshots/lambda_parameter_unused.md | 4 +- src/snapshots/let_polymorphism_records.md | 2 +- src/snapshots/match_expr/complex_list_tags.md | 40 +- .../match_expr/f64_pattern_literal_error.md | 2 +- src/snapshots/match_expr/guards_1.md | 8 +- src/snapshots/match_expr/guards_2.md | 12 +- .../match_expr/list_destructure_variations.md | 6 +- src/snapshots/match_expr/list_patterns.md | 4 +- .../list_patterns_err_multiple_rest.md | 2 +- src/snapshots/match_expr/list_rest_invalid.md | 14 +- src/snapshots/match_expr/list_rest_scoping.md | 6 +- .../match_expr/list_rest_scoping_variables.md | 8 +- src/snapshots/match_expr/middle_rest.md | 2 +- src/snapshots/match_expr/pattern_as_basic.md | 4 +- src/snapshots/match_expr/pattern_as_nested.md | 2 +- src/snapshots/match_expr/tuple_patterns.md | 2 +- src/snapshots/match_expr/wildcard_patterns.md | 2 +- .../nominal_external_fully_qualified.md | 2 +- src/snapshots/pattern_f64_overflow.md | 2 +- src/snapshots/plume_package/Color.md | 4 +- .../function_record_parameter_capture.md | 2 +- .../records/pattern_destructure_nested.md | 2 +- .../records/pattern_destructure_simple.md | 2 +- src/snapshots/rigid_var_instantiation.md | 6 +- .../rigid_var_no_instantiation_error.md | 6 +- src/snapshots/syntax_grab_bag.md | 28 +- src/snapshots/test_exact_pattern_crash.md | 2 +- src/snapshots/type_alias_decl.md | 4 +- src/snapshots/type_annotation_basic.md | 2 +- src/snapshots/type_app_complex_nested.md | 2 +- src/snapshots/type_shadowing_across_scopes.md | 2 +- src/snapshots/type_tag_union_basic.md | 2 +- src/snapshots/type_undeclared_usage.md | 2 +- src/snapshots/unused_vars_block.md | 4 +- src/snapshots/unused_vars_simple.md | 4 +- 69 files changed, 760 insertions(+), 624 deletions(-) diff --git a/src/base/ModuleEnv.zig b/src/base/ModuleEnv.zig index 944f9df613..cd74fc3ed0 100644 --- a/src/base/ModuleEnv.zig +++ b/src/base/ModuleEnv.zig @@ -35,9 +35,15 @@ line_starts: collections.SafeList(u32), /// The source code of this module. Owned by ModuleEnv. source: []const u8 = "", +/// Whether the source is owned by this ModuleEnv (should be freed in deinit) +owns_source: bool = false, + /// The module path (filename). Owned by ModuleEnv. module_path: []const u8 = "", +/// Whether the module_path is owned by this ModuleEnv (should be freed in deinit) +owns_module_path: bool = false, + /// Initialize the module environment. pub fn init(gpa: std.mem.Allocator) Self { // TODO: maybe wire in smarter default based on the initial input text size. @@ -48,9 +54,11 @@ pub fn init(gpa: std.mem.Allocator) Self { .ident_ids_for_slicing = collections.SafeList(Ident.Idx).initCapacity(gpa, 256), .strings = StringLiteral.Store.initCapacityBytes(gpa, 4096), .types = types_mod.Store.initCapacity(gpa, 2048, 512), - .exposed_by_str = collections.SafeStringHashMap(void).init(), - .exposed_nodes = collections.SafeStringHashMap(u16).init(), + .exposed_by_str = collections.SafeStringHashMap(void).initCapacity(gpa, 64), + .exposed_nodes = collections.SafeStringHashMap(u16).initCapacity(gpa, 64), .line_starts = collections.SafeList(u32).initCapacity(gpa, 256), + .owns_source = false, + .owns_module_path = false, }; } @@ -65,10 +73,10 @@ pub fn deinit(self: *Self) void { self.exposed_nodes.deinit(self.gpa); // Free owned source and module path - if (self.source.len > 0) { + if (self.owns_source and self.source.len > 0) { self.gpa.free(self.source); } - if (self.module_path.len > 0) { + if (self.owns_module_path and self.module_path.len > 0) { self.gpa.free(self.module_path); } } diff --git a/src/cache/CacheManager.zig b/src/cache/CacheManager.zig index d86f0c31e2..2717bc4879 100644 --- a/src/cache/CacheManager.zig +++ b/src/cache/CacheManager.zig @@ -282,6 +282,15 @@ pub const CacheManager = struct { const module_env = try self.allocator.create(ModuleEnv); module_env.* = restored.module_env; + // Fix source and module_path pointers since they weren't cached + // Create a placeholder source that won't cause crashes when displayed + const placeholder_source = try self.allocator.dupe(u8, "# Source not available (loaded from cache)"); + module_env.source = placeholder_source; + + // Use a generic module path for cached modules + const cached_module_path = try self.allocator.dupe(u8, ""); + module_env.module_path = cached_module_path; + // Allocate CIR to heap for ownership const cir = try self.allocator.create(CIR); @@ -290,14 +299,12 @@ pub const CacheManager = struct { // Immediately fix env pointer to point to our heap-allocated module_env cir.env = module_env; - // Source content is not cached - provide a placeholder - const source = try self.allocator.dupe(u8, "# Source loaded from cache"); - // Create ProcessResult with proper ownership + // Use the same source as ModuleEnv to avoid inconsistency const process_result = coordinate_simple.ProcessResult{ .cir = cir, .reports = reports, - .source = source, + .source = module_env.source, .was_cached = true, }; diff --git a/src/cache/CacheModule.zig b/src/cache/CacheModule.zig index dfe0f11d19..bd06f4919d 100644 --- a/src/cache/CacheModule.zig +++ b/src/cache/CacheModule.zig @@ -590,6 +590,10 @@ test "create and restore cache" { var module_env = base.ModuleEnv.init(gpa); defer module_env.deinit(); + // Set the source in module_env so canonicalization can access it + module_env.source = try gpa.dupe(u8, source); + module_env.owns_source = true; + var cir = CIR.init(&module_env, "TestModule"); defer cir.deinit(); @@ -665,6 +669,10 @@ test "cache filesystem roundtrip with in-memory storage" { var module_env = base.ModuleEnv.init(gpa); defer module_env.deinit(); + // Set the source in module_env so canonicalization can access it + module_env.source = try gpa.dupe(u8, source); + module_env.owns_source = true; + var cir = CIR.init(&module_env, "TestModule"); defer cir.deinit(); diff --git a/src/check/canonicalize.zig b/src/check/canonicalize.zig index 2ac4de05e1..49c64162a1 100644 --- a/src/check/canonicalize.zig +++ b/src/check/canonicalize.zig @@ -6289,6 +6289,10 @@ test "hexadecimal integer literals" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + env.source = try gpa.dupe(u8, tc.literal); + env.owns_source = true; + var ast = parse.parseExpr(&env, tc.literal); defer ast.deinit(gpa); @@ -6379,6 +6383,10 @@ test "binary integer literals" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + env.source = try gpa.dupe(u8, tc.literal); + env.owns_source = true; + var ast = parse.parseExpr(&env, tc.literal); defer ast.deinit(gpa); @@ -6469,6 +6477,10 @@ test "octal integer literals" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + env.source = try gpa.dupe(u8, tc.literal); + env.owns_source = true; + var ast = parse.parseExpr(&env, tc.literal); defer ast.deinit(gpa); @@ -6559,6 +6571,10 @@ test "integer literals with uppercase base prefixes" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + env.source = try gpa.dupe(u8, tc.literal); + env.owns_source = true; + var ast = parse.parseExpr(&env, tc.literal); defer ast.deinit(gpa); @@ -6951,7 +6967,12 @@ test "record literal uses record_unbound" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); - var ast = parse.parseExpr(&env, "{ x: 42, y: \"hello\" }"); + // Set the source in module_env so canonicalization can access it + const source1 = "{ x: 42, y: \"hello\" }"; + env.source = try gpa.dupe(u8, source1); + env.owns_source = true; + + var ast = parse.parseExpr(&env, source1); defer ast.deinit(gpa); var cir = CIR.init(&env, "Test"); @@ -6987,7 +7008,12 @@ test "record literal uses record_unbound" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); - var ast = parse.parseExpr(&env, "{}"); + // Set the source in module_env so canonicalization can access it + const source2 = "{}"; + env.source = try gpa.dupe(u8, source2); + env.owns_source = true; + + var ast = parse.parseExpr(&env, source2); defer ast.deinit(gpa); var cir = CIR.init(&env, "Test"); @@ -7022,7 +7048,12 @@ test "record literal uses record_unbound" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); - var ast = parse.parseExpr(&env, "{ value: 123 }"); + // Set the source in module_env so canonicalization can access it + const source3 = "{ value: 123 }"; + env.source = try gpa.dupe(u8, source3); + env.owns_source = true; + + var ast = parse.parseExpr(&env, source3); defer ast.deinit(gpa); var cir = CIR.init(&env, "Test"); @@ -7066,7 +7097,12 @@ test "record_unbound basic functionality" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); - var ast = parse.parseExpr(&env, "{ x: 42, y: 99 }"); + // Set the source in module_env so canonicalization can access it + const source = "{ x: 42, y: 99 }"; + env.source = try gpa.dupe(u8, source); + env.owns_source = true; + + var ast = parse.parseExpr(&env, source); defer ast.deinit(gpa); var cir = CIR.init(&env, "Test"); @@ -7108,8 +7144,13 @@ test "record_unbound with multiple fields" { var env = base.ModuleEnv.init(gpa); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + const source = "{ a: 123, b: 456, c: 789 }"; + env.source = try gpa.dupe(u8, source); + env.owns_source = true; + // Create record_unbound with multiple fields - var ast = parse.parseExpr(&env, "{ a: 123, b: 456, c: 789 }"); + var ast = parse.parseExpr(&env, source); defer ast.deinit(gpa); var cir = CIR.init(&env, "Test"); diff --git a/src/check/canonicalize/test/exposed_shadowing_test.zig b/src/check/canonicalize/test/exposed_shadowing_test.zig index 91fec45904..65a40c7b87 100644 --- a/src/check/canonicalize/test/exposed_shadowing_test.zig +++ b/src/check/canonicalize/test/exposed_shadowing_test.zig @@ -21,6 +21,10 @@ test "exposed but not implemented - values" { \\foo = 42 ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -62,6 +66,10 @@ test "exposed but not implemented - types" { \\MyType : [A, B] ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -105,6 +113,10 @@ test "redundant exposed entries" { \\MyType : [A] ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -154,6 +166,10 @@ test "shadowing with exposed items" { \\y = "second" ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -192,6 +208,10 @@ test "shadowing non-exposed items" { \\notExposed = 2 ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -238,6 +258,10 @@ test "exposed items correctly tracked across shadowing" { \\# z is exposed but never defined ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -303,6 +327,10 @@ test "complex case with redundant, shadowing, and not implemented" { \\c = 100 ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -363,6 +391,10 @@ test "exposed_by_str is populated correctly" { \\MyType : [A, B] ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -397,6 +429,10 @@ test "exposed_by_str persists after canonicalization" { \\# z is not defined ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); @@ -431,6 +467,10 @@ test "exposed_by_str never has entries removed" { \\# baz is not implemented ; + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; + var ast = parse.parse(&env, source); defer ast.deinit(allocator); diff --git a/src/check/canonicalize/test/frac_test.zig b/src/check/canonicalize/test/frac_test.zig index b982107d32..1e538a30a6 100644 --- a/src/check/canonicalize/test/frac_test.zig +++ b/src/check/canonicalize/test/frac_test.zig @@ -21,6 +21,10 @@ fn parseAndCanonicalizeFrac(allocator: std.mem.Allocator, source: []const u8) !s const module_env = try allocator.create(base.ModuleEnv); module_env.* = base.ModuleEnv.init(allocator); + // Set the source in module_env so canonicalization can access it + module_env.source = try allocator.dupe(u8, source); + module_env.owns_source = true; + const parse_ast = try allocator.create(parse.AST); parse_ast.* = parse.parseExpr(module_env, source); @@ -304,6 +308,10 @@ test "fractional literal - NaN handling" { test_allocator.destroy(module_env); } + // Set the source in module_env so canonicalization can access it + module_env.source = try test_allocator.dupe(u8, "NaN"); + module_env.owns_source = true; + var parse_ast = parse.parseExpr(module_env, "NaN"); defer parse_ast.deinit(test_allocator); @@ -326,6 +334,10 @@ test "fractional literal - infinity handling" { test_allocator.destroy(module_env); } + // Set the source in module_env so canonicalization can access it + module_env.source = try test_allocator.dupe(u8, "Infinity"); + module_env.owns_source = true; + var parse_ast = parse.parseExpr(module_env, "Infinity"); defer parse_ast.deinit(test_allocator); diff --git a/src/check/canonicalize/test/import_validation_test.zig b/src/check/canonicalize/test/import_validation_test.zig index e9513a7706..f8aea1ead4 100644 --- a/src/check/canonicalize/test/import_validation_test.zig +++ b/src/check/canonicalize/test/import_validation_test.zig @@ -63,6 +63,9 @@ test "import validation - mix of MODULE NOT FOUND, TYPE NOT EXPOSED, VALUE NOT E var parse_env = base.ModuleEnv.init(allocator); defer parse_env.deinit(); try parse_env.calcLineStarts(source); + // Set the source in module_env so canonicalization can access it + parse_env.source = try allocator.dupe(u8, source); + parse_env.owns_source = true; var ast = try parse.parse(&parse_env, &tokens, allocator, .file); defer ast.deinit(); @@ -70,6 +73,9 @@ test "import validation - mix of MODULE NOT FOUND, TYPE NOT EXPOSED, VALUE NOT E var env = base.ModuleEnv.init(allocator); defer env.deinit(); try env.calcLineStarts(source); + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; var cir = CIR.init(&env, "Test"); defer cir.deinit(); @@ -148,6 +154,9 @@ test "import validation - no module_envs provided" { var parse_env = base.ModuleEnv.init(allocator); defer parse_env.deinit(); try parse_env.calcLineStarts(source); + // Set the source in module_env so canonicalization can access it + parse_env.source = try allocator.dupe(u8, source); + parse_env.owns_source = true; var ast = try parse.parse(&parse_env, &tokens, allocator, .file); defer ast.deinit(); @@ -208,6 +217,9 @@ test "import interner - Import.Idx functionality" { // Canonicalize without module validation to focus on Import.Idx var env = base.ModuleEnv.init(allocator); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; try env.calcLineStarts(source); var cir = CIR.init(&env, "Test"); defer cir.deinit(); @@ -296,6 +308,9 @@ test "import interner - comprehensive usage example" { // Canonicalize var env = base.ModuleEnv.init(allocator); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; try env.calcLineStarts(source); var cir = CIR.init(&env, "Test"); defer cir.deinit(); @@ -393,6 +408,9 @@ test "module scopes - imports are only available in their scope" { // Canonicalize without external module validation to focus on scope testing var env = base.ModuleEnv.init(allocator); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; try env.calcLineStarts(source); var cir = CIR.init(&env, "Test"); defer cir.deinit(); @@ -456,6 +474,9 @@ test "module-qualified lookups with e_lookup_external" { // Canonicalize var env = base.ModuleEnv.init(allocator); defer env.deinit(); + // Set the source in module_env so canonicalization can access it + env.source = try allocator.dupe(u8, source); + env.owns_source = true; try env.calcLineStarts(source); var cir = CIR.init(&env, "Test"); defer cir.deinit(); @@ -618,6 +639,9 @@ test "exposed_nodes - tracking CIR node indices for exposed items" { var env2 = base.ModuleEnv.init(allocator); defer env2.deinit(); + // Set the source in module_env so canonicalization can access it + env2.source = try allocator.dupe(u8, source2); + env2.owns_source = true; try env2.calcLineStarts(source2); var cir2 = CIR.init(&env2); defer cir2.deinit(); @@ -658,6 +682,9 @@ test "export count safety - ensures safe u16 casting" { // Test the diagnostic for exactly maxInt(u16) exports var env1 = base.ModuleEnv.init(allocator); defer env1.deinit(); + // Set the source in module_env so canonicalization can access it + env1.source = try allocator.dupe(u8, source); + env1.owns_source = true; var cir1 = CIR.init(&env1); defer cir1.deinit(); diff --git a/src/check/canonicalize/test/int_test.zig b/src/check/canonicalize/test/int_test.zig index 07714fc0cf..3f478ba17a 100644 --- a/src/check/canonicalize/test/int_test.zig +++ b/src/check/canonicalize/test/int_test.zig @@ -20,6 +20,10 @@ fn parseAndCanonicalizeInt(allocator: std.mem.Allocator, source: []const u8) !st const module_env = try allocator.create(base.ModuleEnv); module_env.* = base.ModuleEnv.init(allocator); + // Set the source in module_env so canonicalization can access it + module_env.source = try allocator.dupe(u8, source); + module_env.owns_source = true; + const parse_ast = try allocator.create(parse.AST); parse_ast.* = parse.parseExpr(module_env, source); diff --git a/src/check/let_polymorphism_integration_test.zig b/src/check/let_polymorphism_integration_test.zig index 97a93bbed7..f25cf64e3c 100644 --- a/src/check/let_polymorphism_integration_test.zig +++ b/src/check/let_polymorphism_integration_test.zig @@ -25,6 +25,10 @@ fn typeCheckExpr(allocator: std.mem.Allocator, source: []const u8) !struct { const module_env = try allocator.create(ModuleEnv); module_env.* = ModuleEnv.init(allocator); + // Set the source in module_env so canonicalization can access it + module_env.source = try allocator.dupe(u8, source); + module_env.owns_source = true; + // Parse const parse_ast = try allocator.create(parse.AST); parse_ast.* = parse.parseExpr(module_env, source); @@ -92,6 +96,10 @@ fn typeCheckFile(allocator: std.mem.Allocator, source: []const u8) !struct { const module_env = try allocator.create(ModuleEnv); module_env.* = ModuleEnv.init(allocator); + // Set the source in module_env so canonicalization can access it + module_env.source = try allocator.dupe(u8, source); + module_env.owns_source = true; + // Parse const parse_ast = try allocator.create(parse.AST); parse_ast.* = parse.parse(module_env, source); @@ -164,6 +172,10 @@ fn typeCheckStatement(allocator: std.mem.Allocator, source: []const u8) !struct const module_env = try allocator.create(ModuleEnv); module_env.* = ModuleEnv.init(allocator); + // Set the source in module_env so canonicalization can access it + module_env.source = try allocator.dupe(u8, source); + module_env.owns_source = true; + // Parse const parse_ast = try allocator.create(parse.AST); parse_ast.* = parse.parseStatement(module_env, source); diff --git a/src/coordinate/ModuleGraph.zig b/src/coordinate/ModuleGraph.zig index e84571ac98..769e93033b 100644 --- a/src/coordinate/ModuleGraph.zig +++ b/src/coordinate/ModuleGraph.zig @@ -114,6 +114,10 @@ fn loadOrCompileCanIr( // comment here so we discuss the plan and make the necessary changes. var module_env = base.ModuleEnv.init(gpa); + // Set the source in module_env so canonicalization can access it + module_env.source = try gpa.dupe(u8, contents); + module_env.owns_source = true; + var parse_ir = parse.parse(&module_env, contents); parse_ir.store.emptyScratch(); diff --git a/src/coordinate_simple.zig b/src/coordinate_simple.zig index 805decf1ff..0b1d7ecece 100644 --- a/src/coordinate_simple.zig +++ b/src/coordinate_simple.zig @@ -156,6 +156,10 @@ fn processSourceInternal( // Calculate line starts for region info try module_env.*.calcLineStarts(source); + // Set the source in module_env so canonicalization can access it + module_env.source = try gpa.dupe(u8, source); + module_env.owns_source = true; + // Parse the source code var parse_ast = parse.parse(module_env, source); defer parse_ast.deinit(gpa); diff --git a/src/fmt.zig b/src/fmt.zig index 75e18c700b..d070a0ed91 100644 --- a/src/fmt.zig +++ b/src/fmt.zig @@ -149,6 +149,10 @@ pub fn formatFilePath(gpa: std.mem.Allocator, base_dir: std.fs.Dir, path: []cons var module_env = base.ModuleEnv.init(gpa); defer module_env.deinit(); + // Set the source in module_env so canonicalization can access it + module_env.source = try gpa.dupe(u8, contents); + module_env.owns_source = true; + var parse_ast = parse.parse(&module_env, contents); defer parse_ast.deinit(gpa); @@ -2080,6 +2084,10 @@ fn parseAndFmt(gpa: std.mem.Allocator, input: []const u8, debug: bool) ![]const var module_env = base.ModuleEnv.init(gpa); defer module_env.deinit(); + // Set the source in module_env so canonicalization can access it + module_env.source = try gpa.dupe(u8, input); + module_env.owns_source = true; + var parse_ast = parse.parse(&module_env, input); defer parse_ast.deinit(gpa); diff --git a/src/load/Builder.zig b/src/load/Builder.zig index d925a65b88..ff95f2835d 100644 --- a/src/load/Builder.zig +++ b/src/load/Builder.zig @@ -53,50 +53,63 @@ config: Config, cache_manager: CacheManager, /// Task queue for work items task_queue: *TaskQueue, -/// Module environments indexed by module ID -module_envs: std.AutoHashMap(ModuleId, *ModuleEnv), -/// Parse results indexed by module ID -parse_results: std.AutoHashMap(ModuleId, ParseResult), -/// Canonicalized results indexed by module ID -canonicalized_results: std.AutoHashMap(ModuleId, CanonicalizedModule), -/// Type checked results indexed by module ID -type_checked_results: std.AutoHashMap(ModuleId, TypeCheckedModule), +/// === Builder State === +/// Modules indexed by module ID +modules: std.AutoHashMap(ModuleId, Module), /// Workers (empty in single-threaded mode) workers: []Worker, /// Next module ID to assign next_module_id: ModuleId = 0, /// Mutex for thread-safe operations (null in single-threaded mode) mutex: ?std.Thread.Mutex, - -/// Stores parse result with metadata -pub const ParseResult = struct { - ast: *parse.AST, - module_path: []const u8, // Reference to path owned by ModuleEnv +/// === Data Structures === +/// Compilation phase for a module +pub const ModulePhase = enum { + /// Module has been created but not yet parsed + created, + /// Module has been parsed + parsed, + /// Module has been canonicalized + canonicalized, + /// Module has been type checked + type_checked, }; -/// Stores canonicalized module data -pub const CanonicalizedModule = struct { - /// The canonicalized IR - cir: *canonicalize.CIR, - /// Number of errors found during canonicalization - error_count: u32, - /// Number of warnings found during canonicalization - warning_count: u32, - /// Whether this module was loaded from cache - was_cached: bool = false, - /// Diagnostics found during canonicalization (owned by this struct) - diagnostics: []canonicalize.CIR.Diagnostic, -}; - -/// Stores type checked module data -pub const TypeCheckedModule = struct { - /// The type checked results - solved_types: struct { - problems: @import("../check/check_types/problem.zig").Store, - types: types.Store, +/// Phase-specific data for a module +pub const PhaseData = union(ModulePhase) { + created: void, + parsed: struct { + ast: *parse.AST, }, - /// Number of type errors - type_error_count: u32, + canonicalized: struct { + ast: *parse.AST, // Keep AST for error reporting + cir: *canonicalize.CIR, + error_count: u32, + warning_count: u32, + was_cached: bool, + diagnostics: []canonicalize.CIR.Diagnostic, + }, + type_checked: struct { + ast: *parse.AST, // Keep AST for error reporting + cir: *canonicalize.CIR, // Keep CIR for codegen + canonicalize_error_count: u32, + canonicalize_warning_count: u32, + solved_types: struct { + problems: @import("../check/check_types/problem.zig").Store, + types: types.Store, + }, + type_error_count: u32, + }, +}; + +/// Unified module representation +pub const Module = struct { + /// The module environment (shared across all phases) + env: *ModuleEnv, + /// Current phase and phase-specific data + phase_data: PhaseData, + /// Module path (reference to path owned by ModuleEnv) + module_path: []const u8, }; pub const ModuleId = u32; @@ -204,10 +217,7 @@ pub fn init(config: Config) !Self { .config = config, .cache_manager = cache_manager, .task_queue = task_queue, - .module_envs = std.AutoHashMap(ModuleId, *ModuleEnv).init(config.allocator), - .parse_results = std.AutoHashMap(ModuleId, ParseResult).init(config.allocator), - .canonicalized_results = std.AutoHashMap(ModuleId, CanonicalizedModule).init(config.allocator), - .type_checked_results = std.AutoHashMap(ModuleId, TypeCheckedModule).init(config.allocator), + .modules = std.AutoHashMap(ModuleId, Module).init(config.allocator), .workers = workers, .mutex = mutex, }; @@ -221,44 +231,39 @@ pub fn deinit(self: *Self) void { } self.config.allocator.free(self.workers); - // Clean up type checked results first (no dependency on module environments) - var type_iter = self.type_checked_results.iterator(); - while (type_iter.next()) |entry| { - entry.value_ptr.solved_types.problems.deinit(self.config.allocator); + // Clean up modules + var module_iter = self.modules.iterator(); + while (module_iter.next()) |entry| { + var module = entry.value_ptr; + + // Clean up phase-specific data + switch (module.phase_data) { + .created => {}, + .parsed => |data| { + data.ast.deinit(self.config.allocator); + self.config.allocator.destroy(data.ast); + }, + .canonicalized => |data| { + data.ast.deinit(self.config.allocator); + self.config.allocator.destroy(data.ast); + data.cir.deinit(); + self.config.allocator.destroy(data.cir); + self.config.allocator.free(data.diagnostics); + }, + .type_checked => |data| { + data.ast.deinit(self.config.allocator); + self.config.allocator.destroy(data.ast); + data.cir.deinit(); + self.config.allocator.destroy(data.cir); + @constCast(&data.solved_types.problems).deinit(self.config.allocator); + }, + } + + // Clean up module environment + module.env.deinit(); + self.config.allocator.destroy(module.env); } - self.type_checked_results.deinit(); - - // Clean up canonicalized results (CIR references module environments) - var canon_iter = self.canonicalized_results.iterator(); - while (canon_iter.next()) |entry| { - entry.value_ptr.cir.deinit(); - self.config.allocator.destroy(entry.value_ptr.cir); - self.config.allocator.free(entry.value_ptr.diagnostics); - } - self.canonicalized_results.deinit(); - - // Clean up parse results - var parse_iter = self.parse_results.iterator(); - while (parse_iter.next()) |entry| { - const ast_ptr = entry.value_ptr.ast; - - // Deinit the AST (which frees its internal structures) - ast_ptr.deinit(self.config.allocator); - - // Then free the AST pointer itself - self.config.allocator.destroy(ast_ptr); - - // Note: module_path is owned by ModuleEnv, so we don't free it here - } - self.parse_results.deinit(); - - // Clean up module environments last (after nothing references them) - var env_iter = self.module_envs.iterator(); - while (env_iter.next()) |entry| { - entry.value_ptr.*.deinit(); - self.config.allocator.destroy(entry.value_ptr.*); - } - self.module_envs.deinit(); + self.modules.deinit(); // Clean up task queue self.task_queue.deinit(); @@ -267,6 +272,33 @@ pub fn deinit(self: *Self) void { // Cache manager doesn't need explicit cleanup - it just holds config } +/// Get a module by ID +pub fn getModule(self: *Self, module_id: ModuleId) ?*Module { + if (self.mutex) |*mutex| { + mutex.lock(); + defer mutex.unlock(); + } + + return self.modules.getPtr(module_id); +} + +/// Update a module's phase +fn updateModulePhase(self: *Self, module_id: ModuleId, new_phase_data: PhaseData) !void { + if (self.mutex) |*mutex| { + mutex.lock(); + defer mutex.unlock(); + } + + const module = self.modules.getPtr(module_id) orelse return error.ModuleNotFound; + module.phase_data = new_phase_data; +} + +/// Queue a task +fn queueTask(self: *Self, task_kind: Task.Kind) !void { + const task = Task{ .kind = task_kind }; + try self.task_queue.push(task); +} + /// Build modules starting from the given source file path pub fn build(self: *Self, source_path: []const u8) !void { // Create initial task to load the root module @@ -346,15 +378,11 @@ pub fn processTask(self: *Self, task: Task) !void { try self.loadFile(load.path, load.module_id); self.config.allocator.free(load.path); }, - .parse => |parse_task| { - try self.parseModule(parse_task.module_id, parse_task.source, parse_task.path); - // Don't free source or path here - ownership is transferred to ModuleEnv - }, .canonicalize => |canon| { try self.canonicalizeModule(canon.module_id); }, - .type_check => |type_check_task| { - try self.typeCheckModule(type_check_task.module_id); + .type_check => |tc| { + try self.typeCheckModule(tc.module_id); }, } } @@ -363,7 +391,7 @@ pub fn processTask(self: *Self, task: Task) !void { fn loadFile(self: *Self, path: []const u8, module_id: ModuleId) !void { // Read the file contents const source = try self.config.filesystem.readFile(path, self.config.allocator); - defer self.config.allocator.free(source); + errdefer self.config.allocator.free(source); // Try to load from cache const cache_result = try self.cache_manager.lookup(source, @import("build_options").compiler_version); @@ -372,45 +400,62 @@ fn loadFile(self: *Self, path: []const u8, module_id: ModuleId) !void { .hit => |cached_data| { // Cache hit! The cached_data contains a ProcessResult that was restored from cache - // Store the module environment (already allocated by cache restore) - try self.storeModuleEnv(module_id, cached_data.result.cir.env); + // Update the cached ModuleEnv to use the actual file path + const module_path_copy = try self.config.allocator.dupe(u8, path); + cached_data.result.cir.env.module_path = module_path_copy; - // Store the canonicalized result with the CIR pointer and cached error counts - _ = try self.storeCanonicalizedResultWithCounts(module_id, cached_data.result.cir, true, cached_data.error_count, cached_data.warning_count); + // Create module with cached data + const module = Module{ + .env = cached_data.result.cir.env, + .phase_data = .{ + .canonicalized = .{ + .ast = undefined, // AST not available from cache + .cir = cached_data.result.cir, + .error_count = cached_data.error_count, + .warning_count = cached_data.warning_count, + .was_cached = true, + .diagnostics = &[_]canonicalize.CIR.Diagnostic{}, // No diagnostics from cache + }, + }, + .module_path = module_path_copy, + }; - // Free the unused source and reports from cache - self.config.allocator.free(cached_data.result.source); + if (self.mutex) |*mutex| { + mutex.lock(); + defer mutex.unlock(); + } + + try self.modules.put(module_id, module); + + // Free the reports from cache self.config.allocator.free(cached_data.result.reports); + // Don't free cached_data.result.source - it might be owned by the cached ModuleEnv + // Free our locally read source since we loaded from cache + self.config.allocator.free(source); - // Queue type checking task if there are no errors + // Queue type checking if no errors if (cached_data.error_count == 0) { - const type_check_task = Task{ - .kind = .{ .type_check = .{ - .module_id = module_id, - } }, - }; - try self.task_queue.push(type_check_task); + try self.queueTask(.{ .type_check = .{ .module_id = module_id } }); } return; }, - .miss, .invalid => { - // Cache miss or invalid - continue with normal parsing + .miss => { + // Cache miss - create module and parse + // Don't free source here - createAndParseModule takes ownership + try self.createAndParseModule(module_id, source, path); + return; + }, + .invalid => { + // Cache invalid - continue without caching + // Don't free source here - createAndParseModule takes ownership + try self.createAndParseModule(module_id, source, path); + return; }, } - - // Not in cache, need to parse - const parse_task = Task{ - .kind = .{ .parse = .{ - .module_id = module_id, - .source = try self.config.allocator.dupe(u8, source), - .path = try self.config.allocator.dupe(u8, path), - } }, - }; - try self.task_queue.push(parse_task); } -/// Parse a module -fn parseModule(self: *Self, module_id: ModuleId, source: []const u8, path: []const u8) !void { +/// Create a module and parse it +pub fn createAndParseModule(self: *Self, module_id: ModuleId, source: []const u8, path: []const u8) !void { // Create module environment var module_env = try self.config.allocator.create(ModuleEnv); module_env.* = ModuleEnv.init(self.config.allocator); @@ -419,90 +464,145 @@ fn parseModule(self: *Self, module_id: ModuleId, source: []const u8, path: []con self.config.allocator.destroy(module_env); } - // Transfer ownership of source and path to ModuleEnv + // Transfer ownership of source to ModuleEnv module_env.source = source; - module_env.module_path = path; + module_env.owns_source = true; + // Duplicate path since the caller will free it + module_env.module_path = try self.config.allocator.dupe(u8, path); + module_env.owns_module_path = true; + + // Create module in created phase + const module = Module{ + .env = module_env, + .phase_data = .{ .created = {} }, + .module_path = module_env.module_path, + }; + + if (self.mutex) |*mutex| { + mutex.lock(); + defer mutex.unlock(); + } + + try self.modules.put(module_id, module); + + // Now parse the module + try self.parseModule(module_id); +} + +/// Parse a module +fn parseModule(self: *Self, module_id: ModuleId) !void { + // Get the module + const module = self.getModule(module_id) orelse return error.ModuleNotFound; + + // Ensure module is in created phase + switch (module.phase_data) { + .created => {}, + else => return error.InvalidPhase, + } // Calculate line starts - try module_env.calcLineStarts(source); + try module.env.calcLineStarts(module.env.source); // Parse the source - AST references ModuleEnv which owns the source - const parse_result = parse.parse(module_env, source); + const parse_result = parse.parse(module.env, module.env.source); - // Store the module environment - try self.storeModuleEnv(module_id, module_env); + // Create storage for the AST + const ast_ptr = try self.config.allocator.create(parse.AST); + ast_ptr.* = parse_result; // Check for parse errors - const has_parse_errors = parse_result.tokenize_diagnostics.items.len > 0 or - parse_result.parse_diagnostics.items.len > 0; + const has_parse_errors = ast_ptr.tokenize_diagnostics.items.len > 0 or + ast_ptr.parse_diagnostics.items.len > 0; - // Store the parse result - this transfers ownership of the AST - try self.storeParseResult(module_id, parse_result); + // Update module to parsed phase + try self.updateModulePhase(module_id, .{ .parsed = .{ + .ast = ast_ptr, + } }); // Only queue canonicalization if there are no parse errors if (!has_parse_errors) { - const canon_task = Task{ - .kind = .{ .canonicalize = .{ - .module_id = module_id, - } }, - }; - try self.task_queue.push(canon_task); + try self.queueTask(.{ .canonicalize = .{ .module_id = module_id } }); } } /// Canonicalize a module fn canonicalizeModule(self: *Self, module_id: ModuleId) !void { - // Get the module environment and parse result - const module_env = self.getModuleEnv(module_id) orelse return error.ModuleNotFound; - const parse_result = self.getParseResult(module_id) orelse return error.ParseResultNotFound; + // Get the module + const module = self.getModule(module_id) orelse return error.ModuleNotFound; + + // Ensure module is in parsed phase + const parsed_data = switch (module.phase_data) { + .parsed => |data| data, + else => return error.InvalidPhase, + }; // Create CIR (Canonicalized IR) on the heap so it persists const cir = try self.config.allocator.create(canonicalize.CIR); errdefer self.config.allocator.destroy(cir); // Initialize with the module path as the module name - const module_name = try self.config.allocator.dupe(u8, parse_result.module_path); - defer self.config.allocator.free(module_name); - - cir.* = canonicalize.CIR.init(module_env, module_name); - errdefer cir.deinit(); + cir.* = canonicalize.CIR.init(module.env, module.module_path); // Create the canonicalizer - var canonicalizer = try canonicalize.init(cir, @constCast(parse_result.ast), null); + var canonicalizer = try canonicalize.init(cir, @constCast(parsed_data.ast), null); defer canonicalizer.deinit(); // Canonicalize the file try canonicalizer.canonicalizeFile(); - // Store the canonicalized result - const canon_result = try self.storeCanonicalizedResult(module_id, cir, false); + // Get diagnostics (now non-destructive with our CIR fix) + const diagnostics = cir.getDiagnostics(); + + var error_count: u32 = 0; + var warning_count: u32 = 0; + for (diagnostics) |diagnostic| { + switch (diagnostic) { + .shadowing_warning => warning_count += 1, + else => error_count += 1, + } + } + + // Make a copy of the diagnostics since they're owned by the CIR + const diagnostics_copy = try self.config.allocator.alloc(canonicalize.CIR.Diagnostic, diagnostics.len); + @memcpy(diagnostics_copy, diagnostics); + + // Update module to canonicalized phase + try self.updateModulePhase(module_id, .{ .canonicalized = .{ + .ast = parsed_data.ast, + .cir = cir, + .error_count = error_count, + .warning_count = warning_count, + .was_cached = false, + .diagnostics = diagnostics_copy, + } }); // Store to cache for future use const process_result = coordinate_simple.ProcessResult{ .cir = cir, .reports = &[_]reporting.Report{}, // Reports are not cached - .source = parse_result.ast.env.source, - .error_count = canon_result.error_count, - .warning_count = canon_result.warning_count, + .source = module.env.source, + .error_count = error_count, + .warning_count = warning_count, .was_cached = false, }; - try self.cache_manager.store(parse_result.ast.env.source, @import("build_options").compiler_version, &process_result); + try self.cache_manager.store(module.env.source, @import("build_options").compiler_version, &process_result); // Queue type checking task if there are no errors - if (canon_result.error_count == 0) { - const type_check_task = Task{ - .kind = .{ .type_check = .{ - .module_id = module_id, - } }, - }; - try self.task_queue.push(type_check_task); + if (error_count == 0) { + try self.queueTask(.{ .type_check = .{ .module_id = module_id } }); } } /// Type check a module fn typeCheckModule(self: *Self, module_id: ModuleId) !void { - // Get the canonicalized result - const canon_result = self.getCanonicalizedResult(module_id) orelse return error.CanonicalizedResultNotFound; + // Get the module + const module = self.getModule(module_id) orelse return error.ModuleNotFound; + + // Ensure module is in canonicalized phase + const canon_data = switch (module.phase_data) { + .canonicalized => |data| data, + else => return error.InvalidPhase, + }; // For now, we'll create a simple type checking context // In a real implementation, we'd need to handle imports and other modules @@ -510,8 +610,8 @@ fn typeCheckModule(self: *Self, module_id: ModuleId) !void { var type_checker = try check_types.init( self.config.allocator, - &canon_result.cir.env.types, - @constCast(canon_result.cir), + &module.env.types, + @constCast(canon_data.cir), empty_modules, ); @@ -527,40 +627,25 @@ fn typeCheckModule(self: *Self, module_id: ModuleId) !void { const problems = type_checker.problems; type_checker.problems = problem.Store.initCapacity(self.config.allocator, 64); - // Store the type checked result - const type_checked = TypeCheckedModule{ + // Update module to type checked phase + try self.updateModulePhase(module_id, .{ .type_checked = .{ + .ast = canon_data.ast, + .cir = canon_data.cir, + .canonicalize_error_count = canon_data.error_count, + .canonicalize_warning_count = canon_data.warning_count, .solved_types = .{ .problems = problems, - .types = canon_result.cir.env.types, + .types = module.env.types, }, - .type_error_count = @intCast(type_error_count), - }; - try self.storeTypeCheckedResult(module_id, type_checked); + .type_error_count = type_error_count, + } }); // Now we can safely deinit the type_checker type_checker.deinit(); } /// Store a module environment -pub fn storeModuleEnv(self: *Self, module_id: ModuleId, env: *ModuleEnv) !void { - if (self.mutex) |*mutex| { - mutex.lock(); - defer mutex.unlock(); - } - - try self.module_envs.put(module_id, env); -} - -/// Get a module environment -pub fn getModuleEnv(self: *Self, module_id: ModuleId) ?*ModuleEnv { - if (self.mutex) |*mutex| { - mutex.lock(); - defer mutex.unlock(); - } - - return self.module_envs.get(module_id); -} - +/// Run a single task (for worker threads) /// Allocate a new module ID fn allocateModuleId(self: *Self) ModuleId { if (self.mutex) |*mutex| { @@ -586,117 +671,4 @@ pub fn waitForTask(self: *Self) void { } /// Store a parse result - takes ownership of the AST -fn storeParseResult(self: *Self, module_id: ModuleId, ast: parse.AST) !void { - if (self.mutex) |*mutex| { - mutex.lock(); - defer mutex.unlock(); - } - - // Create storage for the AST - const ast_ptr = try self.config.allocator.create(parse.AST); - - // Move the AST data - this transfers ownership - ast_ptr.* = ast; - - const result = ParseResult{ - .ast = ast_ptr, - .module_path = ast.env.module_path, - }; - - try self.parse_results.put(module_id, result); -} - -/// Get a parse result -pub fn getParseResult(self: *Self, module_id: ModuleId) ?ParseResult { - if (self.mutex) |*mutex| { - mutex.lock(); - defer mutex.unlock(); - } - - return self.parse_results.get(module_id); -} - -/// Store a canonicalized result -fn storeCanonicalizedResult(self: *Self, module_id: ModuleId, cir: *canonicalize.CIR, was_cached: bool) !CanonicalizedModule { - // Get diagnostics (now non-destructive with our CIR fix) - const diagnostics = cir.getDiagnostics(); - - var error_count: u32 = 0; - var warning_count: u32 = 0; - for (diagnostics) |diagnostic| { - switch (diagnostic) { - .shadowing_warning => warning_count += 1, - else => error_count += 1, - } - } - - return self.storeCanonicalizedResultWithDiagnostics(module_id, cir, was_cached, error_count, warning_count, diagnostics); -} - -/// Store a canonicalized result with explicit error/warning counts -fn storeCanonicalizedResultWithCounts(self: *Self, module_id: ModuleId, cir: *canonicalize.CIR, was_cached: bool, error_count: u32, warning_count: u32) !CanonicalizedModule { - // For cached results, we don't have diagnostics - const diagnostics = try self.config.allocator.alloc(canonicalize.CIR.Diagnostic, 0); - return self.storeCanonicalizedResultWithDiagnostics(module_id, cir, was_cached, error_count, warning_count, diagnostics); -} - -/// Store a canonicalized result with explicit diagnostics -fn storeCanonicalizedResultWithDiagnostics(self: *Self, module_id: ModuleId, cir: *canonicalize.CIR, was_cached: bool, error_count: u32, warning_count: u32, diagnostics: []canonicalize.CIR.Diagnostic) !CanonicalizedModule { - if (self.mutex) |*mutex| { - mutex.lock(); - defer mutex.unlock(); - } - - // Make a copy of the diagnostics since they're owned by the CIR - const diagnostics_copy = try self.config.allocator.alloc(canonicalize.CIR.Diagnostic, diagnostics.len); - @memcpy(diagnostics_copy, diagnostics); - - const result = CanonicalizedModule{ - .cir = cir, - .error_count = error_count, - .warning_count = warning_count, - .was_cached = was_cached, - .diagnostics = diagnostics_copy, - }; - - try self.canonicalized_results.put(module_id, result); - return result; -} - -/// Get a canonicalized result -pub fn getCanonicalizedResult(self: *Self, module_id: ModuleId) ?*const CanonicalizedModule { - if (self.mutex) |*mutex| { - mutex.lock(); - defer mutex.unlock(); - } - - if (self.canonicalized_results.getPtr(module_id)) |ptr| { - return ptr; - } - return null; -} - -/// Store a type checked result -fn storeTypeCheckedResult(self: *Self, module_id: ModuleId, result: TypeCheckedModule) !void { - if (self.mutex) |*mutex| { - mutex.lock(); - defer mutex.unlock(); - } - - try self.type_checked_results.put(module_id, result); -} - -/// Get a type checked result -pub fn getTypeCheckedResult(self: *Self, module_id: ModuleId) ?*const TypeCheckedModule { - if (self.mutex) |*mutex| { - mutex.lock(); - defer mutex.unlock(); - } - - if (self.type_checked_results.getPtr(module_id)) |ptr| { - return ptr; - } - return null; -} - const builtin = @import("builtin"); diff --git a/src/load/Task.zig b/src/load/Task.zig index 996a3a0fb4..78ca5d239b 100644 --- a/src/load/Task.zig +++ b/src/load/Task.zig @@ -11,8 +11,6 @@ kind: Kind, pub const Kind = union(enum) { /// Load a file from disk load_file: LoadFile, - /// Parse source code - parse: Parse, /// Canonicalize a module canonicalize: Canonicalize, /// Type check a module @@ -27,16 +25,6 @@ pub const LoadFile = struct { module_id: Builder.ModuleId, }; -/// Parse task data -pub const Parse = struct { - /// Module ID being parsed - module_id: Builder.ModuleId, - /// Source code to parse - source: []const u8, - /// Path to the module file - path: []const u8, -}; - /// Canonicalize task data pub const Canonicalize = struct { /// Module ID to canonicalize diff --git a/src/load/TestRunner.zig b/src/load/TestRunner.zig index 30a862370c..b1136dfc5f 100644 --- a/src/load/TestRunner.zig +++ b/src/load/TestRunner.zig @@ -141,67 +141,39 @@ pub fn runWithRaceConditions(self: *Self, max_concurrent: usize) !void { /// Simulate a deadlock scenario pub fn simulateDeadlock(self: *Self) !void { - // Simulate a deadlock by creating circular dependencies - // This creates tasks that depend on each other in a cycle + // Module IDs - // First, let's drain any existing tasks - while (self.builder.getNextTask()) |_| {} - - // Create a scenario where modules depend on each other circularly - // Module A imports Module B, Module B imports Module C, Module C imports Module A - - // Add parse tasks for three interdependent modules const module_a_id: Builder.ModuleId = 100; const module_b_id: Builder.ModuleId = 101; const module_c_id: Builder.ModuleId = 102; - // Create parse tasks - const parse_a = Task{ - .kind = .{ .parse = .{ - .module_id = module_a_id, - .source = try self.builder.config.allocator.dupe(u8, - \\interface ModuleA - \\ imports [ModuleB] - \\ exposes [valueA] - \\ - \\valueA = ModuleB.valueB + 1 - ), - .path = try self.builder.config.allocator.dupe(u8, "ModuleA.roc"), - } }, - }; + // Create modules directly using createAndParseModule + const source_a = try self.builder.config.allocator.dupe(u8, + \\interface ModuleA + \\ imports [ModuleB] + \\ exposes [valueA] + \\ + \\valueA = ModuleB.valueB + 1 + ); + try self.builder.createAndParseModule(module_a_id, source_a, "ModuleA.roc"); - const parse_b = Task{ - .kind = .{ .parse = .{ - .module_id = module_b_id, - .source = try self.builder.config.allocator.dupe(u8, - \\interface ModuleB - \\ imports [ModuleC] - \\ exposes [valueB] - \\ - \\valueB = ModuleC.valueC + 1 - ), - .path = try self.builder.config.allocator.dupe(u8, "ModuleB.roc"), - } }, - }; + const source_b = try self.builder.config.allocator.dupe(u8, + \\interface ModuleB + \\ imports [ModuleC] + \\ exposes [valueB] + \\ + \\valueB = ModuleC.valueC + 2 + ); + try self.builder.createAndParseModule(module_b_id, source_b, "ModuleB.roc"); - const parse_c = Task{ - .kind = .{ .parse = .{ - .module_id = module_c_id, - .source = try self.builder.config.allocator.dupe(u8, - \\interface ModuleC - \\ imports [ModuleA] - \\ exposes [valueC] - \\ - \\valueC = ModuleA.valueA + 1 - ), - .path = try self.builder.config.allocator.dupe(u8, "ModuleC.roc"), - } }, - }; - - // Push all parse tasks - try self.builder.task_queue.push(parse_a); - try self.builder.task_queue.push(parse_b); - try self.builder.task_queue.push(parse_c); + const source_c = try self.builder.config.allocator.dupe(u8, + \\interface ModuleC + \\ imports [ModuleA] # Circular dependency! + \\ exposes [valueC] + \\ + \\valueC = ModuleA.valueA + 3 + ); + try self.builder.createAndParseModule(module_c_id, source_c, "ModuleC.roc"); // Log the deadlock simulation start try self.log(.{ .task_started = .{ @@ -255,17 +227,13 @@ fn getTaskInfo(self: *Self, task: Task) TaskInfo { .task_type = "load_file", .module_id = load.module_id, }, - .parse => |parse_task| .{ - .task_type = "parse", - .module_id = parse_task.module_id, - }, .canonicalize => |canon| .{ .task_type = "canonicalize", .module_id = canon.module_id, }, - .type_check => |type_check| .{ + .type_check => |tc| .{ .task_type = "type_check", - .module_id = type_check.module_id, + .module_id = tc.module_id, }, }; } diff --git a/src/load/test.zig b/src/load/test.zig index 72ba5529c3..2cfd1646f5 100644 --- a/src/load/test.zig +++ b/src/load/test.zig @@ -46,7 +46,7 @@ test "Builder.init and deinit" { defer builder.deinit(); // Just ensure it initializes and deinitializes without errors - try testing.expect(builder.module_envs.count() == 0); + try testing.expect(builder.modules.count() == 0); } test "single-threaded file loading" { @@ -65,7 +65,7 @@ test "single-threaded file loading" { // Don't actually run build() as it will try to parse // Just test that we can create and destroy a builder - try testing.expect(builder.module_envs.count() == 0); + try testing.expect(builder.modules.count() == 0); } test "multi-threaded file loading" { diff --git a/src/main.zig b/src/main.zig index 20fbd10053..40a834d2d4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -9,6 +9,7 @@ const collections = @import("collections.zig"); const reporting = @import("reporting.zig"); const load = @import("load/mod.zig"); const cache = @import("cache/mod.zig"); +const canonicalize = @import("check/canonicalize.zig"); const tracy = @import("tracy.zig"); const Filesystem = @import("fs/Filesystem.zig"); @@ -185,16 +186,25 @@ fn rocCheck(gpa: Allocator, args: cli_args.CheckArgs) !void { // Process diagnostics while builder is still alive { - // Check if we have a canonicalized result (either from cache or fresh compilation) - if (builder.getCanonicalizedResult(0)) |canon_result| { - // Count errors and warnings - total_errors += canon_result.error_count; - total_warnings += canon_result.warning_count; - was_cached = canon_result.was_cached; - - // Check if type checking was done - if (builder.getTypeCheckedResult(0)) |type_result| { - total_errors += type_result.type_error_count; + // Check if we have a module + if (builder.getModule(0)) |module| { + switch (module.phase_data) { + .created, .parsed => { + // Module didn't make it past parsing + }, + .canonicalized => |canon_data| { + // Count errors and warnings from canonicalization + total_errors += canon_data.error_count; + total_warnings += canon_data.warning_count; + was_cached = canon_data.was_cached; + }, + .type_checked => |tc_data| { + // Count errors and warnings from both phases + total_errors += tc_data.canonicalize_error_count; + total_warnings += tc_data.canonicalize_warning_count; + total_errors += tc_data.type_error_count; + was_cached = false; // Type checked means fresh compilation + }, } // If loaded from cache, we're done with counting @@ -202,65 +212,16 @@ fn rocCheck(gpa: Allocator, args: cli_args.CheckArgs) !void { // For cached results, we don't generate detailed reports // The user can use --no-cache to see detailed errors } else { - // For fresh compilation, check parse results for detailed error reporting - if (builder.getParseResult(0)) |parse_result| { - const ast = parse_result.ast; - // Make a copy of the filename to ensure it's not freed memory - const filename = try gpa.dupe(u8, parse_result.module_path); - defer gpa.free(filename); + // For fresh compilation, get AST for detailed error reporting + const ast = switch (module.phase_data) { + .created => unreachable, + .parsed => |data| data.ast, + .canonicalized => |data| data.ast, + .type_checked => |data| data.ast, + }; - // Count parse errors - const tokenize_error_count = ast.tokenize_diagnostics.items.len; - const parse_error_count = ast.parse_diagnostics.items.len; - total_errors += @intCast(tokenize_error_count + parse_error_count); - - // Convert tokenize diagnostics to reports - if (tokenize_error_count > 0) { - for (ast.tokenize_diagnostics.items) |diagnostic| { - const report = ast.tokenizeDiagnosticToReport(diagnostic, gpa) catch |err| { - stderr.print("Error converting tokenize diagnostic to report: {}\n", .{err}) catch {}; - continue; - }; - try all_reports.append(report); - } - } - - // Convert parse diagnostics to reports - if (parse_error_count > 0) { - for (ast.parse_diagnostics.items) |diagnostic| { - if (builder.getModuleEnv(0)) |module_env| { - const report = ast.parseDiagnosticToReport(module_env, diagnostic, gpa, filename) catch |err| { - stderr.print("Error converting parse diagnostic to report: {}\n", .{err}) catch {}; - continue; - }; - try all_reports.append(report); - } - } - } - - // If there were no parse errors, convert CIR diagnostics - if (tokenize_error_count == 0 and parse_error_count == 0 and (total_errors > 0 or total_warnings > 0)) { - // Use stored diagnostics from CanonicalizedModule - const diagnostics = canon_result.diagnostics; - - for (diagnostics) |diagnostic| { - // Create report with owned data to avoid dangling references - const report = @constCast(canon_result.cir).diagnosticToReport(diagnostic, gpa, null, filename) catch |err| { - stderr.print("Error converting diagnostic to report: {}\n", .{err}) catch {}; - continue; - }; - try all_reports.append(report); - } - } - } - } - } else { - // No canonicalized result - could be parse error or file not found - if (builder.getParseResult(0)) |parse_result| { - // We have parse results, so there must have been parse errors - const ast = parse_result.ast; // Make a copy of the filename to ensure it's not freed memory - const filename = try gpa.dupe(u8, parse_result.module_path); + const filename = try gpa.dupe(u8, module.module_path); defer gpa.free(filename); // Count parse errors @@ -282,20 +243,84 @@ fn rocCheck(gpa: Allocator, args: cli_args.CheckArgs) !void { // Convert parse diagnostics to reports if (parse_error_count > 0) { for (ast.parse_diagnostics.items) |diagnostic| { - if (builder.getModuleEnv(0)) |module_env| { - const report = ast.parseDiagnosticToReport(module_env, diagnostic, gpa, filename) catch |err| { - stderr.print("Error converting parse diagnostic to report: {}\n", .{err}) catch {}; - continue; - }; - try all_reports.append(report); - } + const report = ast.parseDiagnosticToReport(module.env, diagnostic, gpa, filename) catch |err| { + stderr.print("Error converting parse diagnostic to report: {}\n", .{err}) catch {}; + continue; + }; + try all_reports.append(report); } } - } else { - // No parse result - file not found or other error - stderr.print("Error: Failed to load {s}\n", .{args.path}) catch {}; - builder.deinit(); - std.process.exit(1); + + // If there were no parse errors, convert CIR diagnostics + if (tokenize_error_count == 0 and parse_error_count == 0 and (total_errors > 0 or total_warnings > 0)) { + // Get diagnostics from canonicalized or type checked phase + const diagnostics = switch (module.phase_data) { + .created, .parsed => unreachable, + .canonicalized => |data| data.diagnostics, + .type_checked => blk: { + // For type checked, we might want both canon and type diagnostics + // For now, just use empty since type errors aren't converted to reports yet + break :blk &[_]canonicalize.CIR.Diagnostic{}; + }, + }; + + const cir = switch (module.phase_data) { + .created, .parsed => unreachable, + .canonicalized => |data| data.cir, + .type_checked => |data| data.cir, + }; + + for (diagnostics) |diagnostic| { + // Create report with owned data to avoid dangling references + const report = @constCast(cir).diagnosticToReport(diagnostic, gpa, module.env.source, filename) catch |err| { + stderr.print("Error converting diagnostic to report: {}\n", .{err}) catch {}; + continue; + }; + try all_reports.append(report); + } + } + } + } else { + // No module found - file not found or other error + stderr.print("Error: Failed to load {s}\n", .{args.path}) catch {}; + builder.deinit(); + std.process.exit(1); + } + } + + // If we only got to parse phase, handle parse errors + if (builder.getModule(0)) |module| { + if (module.phase_data == .parsed) { + const ast = module.phase_data.parsed.ast; + // Make a copy of the filename to ensure it's not freed memory + const filename = try gpa.dupe(u8, module.module_path); + defer gpa.free(filename); + + // Count parse errors + const tokenize_error_count = ast.tokenize_diagnostics.items.len; + const parse_error_count = ast.parse_diagnostics.items.len; + total_errors += @intCast(tokenize_error_count + parse_error_count); + + // Convert tokenize diagnostics to reports + if (tokenize_error_count > 0) { + for (ast.tokenize_diagnostics.items) |diagnostic| { + const report = ast.tokenizeDiagnosticToReport(diagnostic, gpa) catch |err| { + stderr.print("Error converting tokenize diagnostic to report: {}\n", .{err}) catch {}; + continue; + }; + try all_reports.append(report); + } + } + + // Convert parse diagnostics to reports + if (parse_error_count > 0) { + for (ast.parse_diagnostics.items) |diagnostic| { + const report = ast.parseDiagnosticToReport(module.env, diagnostic, gpa, filename) catch |err| { + stderr.print("Error converting parse diagnostic to report: {}\n", .{err}) catch {}; + continue; + }; + try all_reports.append(report); + } } } } @@ -305,9 +330,6 @@ fn rocCheck(gpa: Allocator, args: cli_args.CheckArgs) !void { builder.cache_manager.printStats(gpa); } - // Now we can safely clean up the builder - builder.deinit(); - // Display results if (was_cached and (total_errors > 0 or total_warnings > 0)) { // For cached results with errors, just show the count @@ -344,6 +366,10 @@ fn rocCheck(gpa: Allocator, args: cli_args.CheckArgs) !void { const cache_status = if (was_cached) " (loaded from cache)" else ""; stdout.print(" for {s}{s}\n", .{ args.path, cache_status }) catch {}; } + + // Clean up the builder after we're done rendering reports + // This must be done after rendering because reports contain references to source text + builder.deinit(); } fn rocDocs(gpa: Allocator, args: cli_args.DocsArgs) !void { diff --git a/src/snapshot.zig b/src/snapshot.zig index 925c80fc5a..414e2fe5a9 100644 --- a/src/snapshot.zig +++ b/src/snapshot.zig @@ -373,6 +373,10 @@ fn processRocFileAsSnapshotWithExpected(allocator: Allocator, output_path: []con var module_env = base.ModuleEnv.init(allocator); defer module_env.deinit(); + // Duplicate source for ModuleEnv to own (it will free it in deinit) + module_env.source = try allocator.dupe(u8, roc_content); + module_env.owns_source = true; + // Parse the content var ast = parse.parse(&module_env, roc_content); defer ast.deinit(allocator); @@ -1038,7 +1042,7 @@ fn generateProblemsSection(output: *DualOutput, parse_ast: *AST, can_ir: *CIR, s // Canonicalization Diagnostics const diagnostics = can_ir.getDiagnostics(); - defer output.gpa.free(diagnostics); + // Note: getDiagnostics returns cached diagnostics owned by CIR - don't free them here for (diagnostics) |diagnostic| { canonicalize_problems += 1; var report: reporting.Report = can_ir.diagnosticToReport(diagnostic, output.gpa, content.source, snapshot_path) catch |err| { @@ -1564,7 +1568,10 @@ fn processSnapshotFileUnified(gpa: Allocator, snapshot_path: []const u8, maybe_f var module_env = base.ModuleEnv.init(gpa); defer module_env.deinit(); - // Parse the source code (ONCE) + // Duplicate source for ModuleEnv to own (it will free it in deinit) + module_env.source = try gpa.dupe(u8, content.source); + module_env.owns_source = true; + var parse_ast = switch (content.meta.node_type) { .file => parse.parse(&module_env, content.source), .header => parse.parseHeader(&module_env, content.source), diff --git a/src/snapshots/can_import_exposing_types.md b/src/snapshots/can_import_exposing_types.md index 6524a9ebec..a782ee605f 100644 --- a/src/snapshots/can_import_exposing_types.md +++ b/src/snapshots/can_import_exposing_types.md @@ -457,7 +457,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``value`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_value` to suppress this warning. -The unused variable is declared here: + **can_import_exposing_types.md:52:12:52:17:** ```roc Ok(value) => Ok({ body: Json.encode value, status: httpStatus }) @@ -491,7 +491,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``httpStatus`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_httpStatus` to suppress this warning. -The unused variable is declared here: + **can_import_exposing_types.md:52:60:52:70:** ```roc Ok(value) => Ok({ body: Json.encode value, status: httpStatus }) @@ -510,7 +510,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``httpStatus`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_httpStatus` to suppress this warning. -The unused variable is declared here: + **can_import_exposing_types.md:50:31:50:41:** ```roc combineResults = |jsonResult, httpStatus| diff --git a/src/snapshots/can_import_type_annotations.md b/src/snapshots/can_import_type_annotations.md index c136526489..ed50eba86a 100644 --- a/src/snapshots/can_import_type_annotations.md +++ b/src/snapshots/can_import_type_annotations.md @@ -149,7 +149,7 @@ processRequest : Request -> Response Variable ``req`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_req` to suppress this warning. -The unused variable is declared here: + **can_import_type_annotations.md:8:19:8:22:** ```roc processRequest = |req| Http.defaultResponse @@ -165,7 +165,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``data`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_data` to suppress this warning. -The unused variable is declared here: + **can_import_type_annotations.md:17:12:17:16:** ```roc Ok(data) => Ok(Http.success data) diff --git a/src/snapshots/can_import_unresolved_qualified.md b/src/snapshots/can_import_unresolved_qualified.md index 99a6d2e944..151c5f839f 100644 --- a/src/snapshots/can_import_unresolved_qualified.md +++ b/src/snapshots/can_import_unresolved_qualified.md @@ -40,7 +40,7 @@ UNUSED VARIABLE - can_import_unresolved_qualified.md:15:19:15:22 Variable ``req`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_req` to suppress this warning. -The unused variable is declared here: + **can_import_unresolved_qualified.md:15:19:15:22:** ```roc processRequest = |req| Http.Server.defaultResponse diff --git a/src/snapshots/can_list_rest_types.md b/src/snapshots/can_list_rest_types.md index d0c639d12e..7360fb0610 100644 --- a/src/snapshots/can_list_rest_types.md +++ b/src/snapshots/can_list_rest_types.md @@ -29,7 +29,7 @@ match numbers { Variable ``first`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_first` to suppress this warning. -The unused variable is declared here: + **can_list_rest_types.md:2:6:2:11:** ```roc [first, .. as restNums] => restNums diff --git a/src/snapshots/can_var_scoping_regular_var.md b/src/snapshots/can_var_scoping_regular_var.md index 82ade26d79..550f107005 100644 --- a/src/snapshots/can_var_scoping_regular_var.md +++ b/src/snapshots/can_var_scoping_regular_var.md @@ -42,7 +42,7 @@ Variables declared with `var` can only be reassigned within the same function sc Variable ``items`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_items` to suppress this warning. -The unused variable is declared here: + **can_var_scoping_regular_var.md:4:17:4:22:** ```roc processItems = |items| { diff --git a/src/snapshots/can_var_scoping_var_redeclaration.md b/src/snapshots/can_var_scoping_var_redeclaration.md index b0d11cc056..31a9007f80 100644 --- a/src/snapshots/can_var_scoping_var_redeclaration.md +++ b/src/snapshots/can_var_scoping_var_redeclaration.md @@ -43,7 +43,7 @@ But `x_` was already defined here: Variable ``x_`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x_` to suppress this warning. -The unused variable is declared here: + **can_var_scoping_var_redeclaration.md:6:2:7:4:** ```roc var x_ = 10 # Redeclare var - should warn but proceed diff --git a/src/snapshots/crash_and_ellipsis_test.md b/src/snapshots/crash_and_ellipsis_test.md index 0daaebb891..871b32873c 100644 --- a/src/snapshots/crash_and_ellipsis_test.md +++ b/src/snapshots/crash_and_ellipsis_test.md @@ -91,7 +91,7 @@ Only definitions, type annotations, and imports are allowed at the top level. Variable ``result1`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_result1` to suppress this warning. -The unused variable is declared here: + **crash_and_ellipsis_test.md:16:5:16:12:** ```roc result1 = testEllipsis(42) @@ -103,7 +103,7 @@ The unused variable is declared here: Variable ``result2`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_result2` to suppress this warning. -The unused variable is declared here: + **crash_and_ellipsis_test.md:17:5:17:12:** ```roc result2 = testCrash(42) @@ -115,7 +115,7 @@ The unused variable is declared here: Variable ``result3`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_result3` to suppress this warning. -The unused variable is declared here: + **crash_and_ellipsis_test.md:18:5:18:12:** ```roc result3 = testCrashSimple(42) diff --git a/src/snapshots/expr/block_pattern_unify.md b/src/snapshots/expr/block_pattern_unify.md index df13160c3c..c9962848be 100644 --- a/src/snapshots/expr/block_pattern_unify.md +++ b/src/snapshots/expr/block_pattern_unify.md @@ -19,7 +19,7 @@ UNUSED VARIABLE - block_pattern_unify.md:3:5:3:8 Variable ``str`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_str` to suppress this warning. -The unused variable is declared here: + **block_pattern_unify.md:3:5:3:8:** ```roc str = "hello" diff --git a/src/snapshots/expr/tuple_comprehensive.md b/src/snapshots/expr/tuple_comprehensive.md index bf10e2fede..9e64996768 100644 --- a/src/snapshots/expr/tuple_comprehensive.md +++ b/src/snapshots/expr/tuple_comprehensive.md @@ -49,7 +49,7 @@ If you want to represent nothing, try using an empty record: `{}`. Variable ``with_lambda`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_with_lambda` to suppress this warning. -The unused variable is declared here: + **tuple_comprehensive.md:16:2:16:13:** ```roc with_lambda = (|n| n + 1, 42) @@ -61,7 +61,7 @@ The unused variable is declared here: Variable ``single`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_single` to suppress this warning. -The unused variable is declared here: + **tuple_comprehensive.md:10:2:10:8:** ```roc single = (42) @@ -73,7 +73,7 @@ The unused variable is declared here: Variable ``pair`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_pair` to suppress this warning. -The unused variable is declared here: + **tuple_comprehensive.md:11:2:11:6:** ```roc pair = (1, 2) @@ -85,7 +85,7 @@ The unused variable is declared here: Variable ``nested`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_nested` to suppress this warning. -The unused variable is declared here: + **tuple_comprehensive.md:13:2:13:8:** ```roc nested = ((1, 2), (3, 4)) @@ -97,7 +97,7 @@ The unused variable is declared here: Variable ``triple`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_triple` to suppress this warning. -The unused variable is declared here: + **tuple_comprehensive.md:12:2:12:8:** ```roc triple = (1, "hello", True) @@ -109,7 +109,7 @@ The unused variable is declared here: Variable ``mixed`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_mixed` to suppress this warning. -The unused variable is declared here: + **tuple_comprehensive.md:14:2:14:7:** ```roc mixed = (add_one(5), "world", [1, 2, 3]) @@ -121,7 +121,7 @@ The unused variable is declared here: Variable ``with_vars`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_with_vars` to suppress this warning. -The unused variable is declared here: + **tuple_comprehensive.md:15:2:15:11:** ```roc with_vars = (x, y, z) diff --git a/src/snapshots/fuzz_crash/fuzz_crash_019.md b/src/snapshots/fuzz_crash/fuzz_crash_019.md index cafec5708e..3dc25726c3 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_019.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_019.md @@ -293,7 +293,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``lue`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_lue` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_019.md:52:11:52:14:** ```roc match a {lue { @@ -316,7 +316,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``er`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_er` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_019.md:57:2:57:4:** ```roc er #ent @@ -339,7 +339,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``est`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_est` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_019.md:60:12:60:15:** ```roc [1, 2, 3,est]123 @@ -596,7 +596,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``i`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_i` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_019.md:87:2:87:3:** ```roc i= "H, ${d}" @@ -608,7 +608,7 @@ The unused variable is declared here: Variable ``w`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_w` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_019.md:76:2:76:3:** ```roc w = "d" @@ -620,7 +620,7 @@ The unused variable is declared here: Variable ``t`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_t` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_019.md:88:1:88:2:** ```roc t = [ @@ -632,7 +632,7 @@ t = [ Variable ``rd`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rd` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_019.md:96:2:96:4:** ```roc rd = { foo: 123, bar: "H", baz: tag, qux: Ok(world),ned } diff --git a/src/snapshots/fuzz_crash/fuzz_crash_020.md b/src/snapshots/fuzz_crash/fuzz_crash_020.md index 4a00f44f1b..35f3bb7078 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_020.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_020.md @@ -304,7 +304,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``lue`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_lue` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_020.md:52:11:52:14:** ```roc match a {lue { @@ -327,7 +327,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``er`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_er` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_020.md:57:2:57:4:** ```roc er #ent @@ -350,7 +350,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``est`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_est` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_020.md:60:12:60:15:** ```roc [1, 2, 3,est]123 @@ -607,7 +607,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``t`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_t` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_020.md:88:1:88:2:** ```roc t = [ @@ -619,7 +619,7 @@ t = [ Variable ``rd`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rd` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_020.md:96:2:96:4:** ```roc rd = { foo: 123, bar: "H", baz: tag, qux: Ok(world),ned } @@ -631,7 +631,7 @@ The unused variable is declared here: Variable ``w`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_w` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_020.md:76:2:76:3:** ```roc w = "d" @@ -643,7 +643,7 @@ The unused variable is declared here: Variable ``i`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_i` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_020.md:87:2:87:3:** ```roc i= "H, ${d}" diff --git a/src/snapshots/fuzz_crash/fuzz_crash_022.md b/src/snapshots/fuzz_crash/fuzz_crash_022.md index d7a012fb08..8fd7d42bbf 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_022.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_022.md @@ -119,7 +119,7 @@ The condition must be a valid expression that evaluates to a `Bool` value (`Bool Variable ``id`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_id` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_022.md:6:12:6:14:** ```roc getUser = |id| if (id > 1!) "big" else "l" diff --git a/src/snapshots/fuzz_crash/fuzz_crash_023.md b/src/snapshots/fuzz_crash/fuzz_crash_023.md index 5f4a17410f..37363e4e80 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_023.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_023.md @@ -1092,7 +1092,7 @@ This pattern contains invalid syntax or uses unsupported features. Variable ``lower`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_lower` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:97:3:97:8:** ```roc lower # After pattern comment @@ -1104,7 +1104,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:102:19:102:23:** ```roc [1, 2, 3, .. as rest] # After pattern comment @@ -1120,7 +1120,7 @@ Let us know if you want to help! Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:108:23:108:27:** ```roc [1, 2 | 5, 3, .. as rest] => 123 @@ -1136,7 +1136,7 @@ Let us know if you want to help! Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:115:6:115:10:** ```roc rest, # After last pattern in list @@ -1156,7 +1156,7 @@ Let us know if you want to help! Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:121:21:121:29:** ```roc { foo: 1, bar: 2, ..rest } => 12->add(34) @@ -1168,7 +1168,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:127:4:128:10:** ```roc .. # After spread operator @@ -1188,7 +1188,7 @@ Let us know if you want to help! Variable ``b`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_b` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:82:2:82:3:** ```roc b, @@ -1314,7 +1314,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``multiline_tuple`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_multiline_tuple` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:180:2:180:17:** ```roc multiline_tuple = ( @@ -1326,7 +1326,7 @@ The unused variable is declared here: Variable ``record`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_record` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:178:2:178:8:** ```roc record = { foo: 123, bar: "Hello", ;az: tag, qux: Ok(world), punned } @@ -1338,7 +1338,7 @@ The unused variable is declared here: Variable ``tag_with_payload`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_tag_with_payload` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:164:2:164:18:** ```roc tag_with_payload = Ok(number) @@ -1350,7 +1350,7 @@ The unused variable is declared here: Variable ``list`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_list` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:166:2:166:6:** ```roc list = [ @@ -1362,7 +1362,7 @@ The unused variable is declared here: Variable ``bin_op_result`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_bin_op_result` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:188:2:188:15:** ```roc bin_op_result = Err(foo) ?? 12 > 5 * 5 or 13 + 2 < 5 and 10 - 1 >= 16 or 12 <= 3 / 5 @@ -1374,7 +1374,7 @@ The unused variable is declared here: Variable ``static_dispatch_style`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_static_dispatch_style` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:189:2:189:23:** ```roc static_dispatch_style = some_fn(arg1)?.static_dispatch_method()?.next_static_dispatch_method()?.record_field? @@ -1386,7 +1386,7 @@ The unused variable is declared here: Variable ``interpolated`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_interpolated` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_023.md:165:2:165:14:** ```roc interpolated = "Hello, ${world}" diff --git a/src/snapshots/fuzz_crash/fuzz_crash_027.md b/src/snapshots/fuzz_crash/fuzz_crash_027.md index 2143243264..33e49b0012 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_027.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_027.md @@ -520,7 +520,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``lue`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_lue` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:64:11:64:14:** ```roc match a {lue | Red => { @@ -543,7 +543,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:70:38:70:42:** ```roc "foo" | "bar" => 20[1, 2, 3, .. as rest] # Aftet @@ -559,7 +559,7 @@ Let us know if you want to help! Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:74:23:74:27:** ```roc [1, 2 | 5, 3, .. as rest] => 123 @@ -571,7 +571,7 @@ The unused variable is declared here: Variable ``ist`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_ist` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:76:1:76:4:** ```roc ist @@ -591,7 +591,7 @@ Let us know if you want to help! Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:82:21:82:29:** ```roc { foo: 1, bar: 2, ..rest } => 12->add(34) @@ -611,7 +611,7 @@ Let us know if you want to help! Variable ``b`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_b` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:62:2:62:3:** ```roc b, @@ -752,7 +752,7 @@ tuple : Value((a, b, c)) Variable ``record`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_record` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:131:2:131:8:** ```roc record = { foo: 123, bar: "Hello", baz: tag, qux: Ok(world), punned } @@ -764,7 +764,7 @@ The unused variable is declared here: Variable ``list`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_list` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:121:2:121:6:** ```roc list = [ @@ -776,7 +776,7 @@ The unused variable is declared here: Variable ``m_tuple`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_m_tuple` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:133:2:133:9:** ```roc m_tuple = ( @@ -788,7 +788,7 @@ The unused variable is declared here: Variable ``stale`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_stale` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:142:2:142:7:** ```roc stale = some_fn(arg1)?.statod()?.ned()?.recd? @@ -800,7 +800,7 @@ The unused variable is declared here: Variable ``empty`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_empty` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:151:1:151:6:** ```roc empty = {} @@ -812,7 +812,7 @@ empty = {} Variable ``tag_with`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_tag_with` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:119:2:119:10:** ```roc tag_with = Ok(number) @@ -824,7 +824,7 @@ The unused variable is declared here: Variable ``bsult`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_bsult` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:141:2:141:7:** ```roc bsult = Err(foo) ?? 12 > 5 * 5 or 13 + 2 < 5 and 10 - 1 >= 16 or 12 <= 3 / 5 @@ -836,7 +836,7 @@ The unused variable is declared here: Variable ``ited`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_ited` to suppress this warning. -The unused variable is declared here: + **fuzz_crash_027.md:120:2:120:6:** ```roc ited = "Hello, ${world}" diff --git a/src/snapshots/fuzz_crash/fuzz_crash_028.md b/src/snapshots/fuzz_crash/fuzz_crash_028.md index d8d88ba00ddd17d5b1b4debad2f6e40cd88ce4ca..cba7ceb4acdfb1a2a285e343a930e9c67ef7a2af 100644 GIT binary patch delta 122 zcmcaPhvml%mJQqFCm)g)-TXm*B_o(|S@AlA@kBX;2`tj4RtI6&Y4UP|L?*YITn5vV nOdo;ib!K4x=H2EZV7-$$EnkAQ>R7Qr49l{<4KbtM?$&t#fUq+C delta 512 zcmew{gXQKNmJQqFWkWJj6-x6;i&Ik+$`Xq*6O(dM6*7wzQc{z15{o9=i^*<2Ex(eH z2xXm$*NIV9s+_?@glV5t>xfa-s=>=m*tE&ZjV}|Ss^8=h5vtlui7;z(o|y;{p)q;7 b`Afo9Zk}qvLWE(P*IC{sCd}s9+&T{c3&*;f diff --git a/src/snapshots/hello_world_with_block.md b/src/snapshots/hello_world_with_block.md index 52361c09d0..be5aa45c13 100644 --- a/src/snapshots/hello_world_with_block.md +++ b/src/snapshots/hello_world_with_block.md @@ -25,7 +25,7 @@ UNUSED VARIABLE - hello_world_with_block.md:9:2:9:7 Variable ``world`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_world` to suppress this warning. -The unused variable is declared here: + **hello_world_with_block.md:9:2:9:7:** ```roc world = "World" diff --git a/src/snapshots/lambda_parameter_unused.md b/src/snapshots/lambda_parameter_unused.md index cc5bea480d..e53dcc1969 100644 --- a/src/snapshots/lambda_parameter_unused.md +++ b/src/snapshots/lambda_parameter_unused.md @@ -39,7 +39,7 @@ UNDERSCORE VARIABLE USED - lambda_parameter_unused.md:9:22:9:29 Variable ``unused`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_unused` to suppress this warning. -The unused variable is declared here: + **lambda_parameter_unused.md:5:8:5:14:** ```roc add = |unused| 42 @@ -51,7 +51,7 @@ add = |unused| 42 Variable ``_factor`` is prefixed with an underscore but is actually used. Variables prefixed with `_` are intended to be unused. Remove the underscore prefix: `factor`. -The underscore variable is declared here: + **lambda_parameter_unused.md:9:22:9:29:** ```roc multiply = |_factor| _factor * 2 diff --git a/src/snapshots/let_polymorphism_records.md b/src/snapshots/let_polymorphism_records.md index ab3609e153..be92d05e53 100644 --- a/src/snapshots/let_polymorphism_records.md +++ b/src/snapshots/let_polymorphism_records.md @@ -62,7 +62,7 @@ update_data = |container, new_value| { container & data: new_value } Variable ``new_value`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_new_value` to suppress this warning. -The unused variable is declared here: + **let_polymorphism_records.md:19:27:19:36:** ```roc update_data = |container, new_value| { container & data: new_value } diff --git a/src/snapshots/match_expr/complex_list_tags.md b/src/snapshots/match_expr/complex_list_tags.md index 3a2ef6ae50..d1f8f9741a 100644 --- a/src/snapshots/match_expr/complex_list_tags.md +++ b/src/snapshots/match_expr/complex_list_tags.md @@ -542,7 +542,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``y`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_y` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:3:15:3:16:** ```roc [Click(x, y)] => "single click at (${Num.toStr x}, ${Num.toStr y})" @@ -554,7 +554,7 @@ The unused variable is declared here: Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:3:12:3:13:** ```roc [Click(x, y)] => "single click at (${Num.toStr x}, ${Num.toStr y})" @@ -591,7 +591,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``y`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_y` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:3:68:3:69:** ```roc [Click(x, y)] => "single click at (${Num.toStr x}, ${Num.toStr y})" @@ -614,7 +614,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``key`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_key` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:4:15:4:18:** ```roc [KeyPress(key), .. as rest] => "key ${key} pressed, ${Num.toStr (List.len rest)} more events" @@ -626,7 +626,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:4:27:4:31:** ```roc [KeyPress(key), .. as rest] => "key ${key} pressed, ${Num.toStr (List.len rest)} more events" @@ -649,7 +649,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``len`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_len` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:4:70:4:78:** ```roc [KeyPress(key), .. as rest] => "key ${key} pressed, ${Num.toStr (List.len rest)} more events" @@ -679,7 +679,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``others`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_others` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:5:42:5:48:** ```roc [Move(dx, dy), Move(dx2, dy2), .. as others] => "moved ${Num.toStr dx},${Num.toStr dy} then ${Num.toStr dx2},${Num.toStr dy2}" @@ -691,7 +691,7 @@ The unused variable is declared here: Variable ``dy2`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_dy2` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:5:30:5:33:** ```roc [Move(dx, dy), Move(dx2, dy2), .. as others] => "moved ${Num.toStr dx},${Num.toStr dy} then ${Num.toStr dx2},${Num.toStr dy2}" @@ -703,7 +703,7 @@ The unused variable is declared here: Variable ``dx2`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_dx2` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:5:25:5:28:** ```roc [Move(dx, dy), Move(dx2, dy2), .. as others] => "moved ${Num.toStr dx},${Num.toStr dy} then ${Num.toStr dx2},${Num.toStr dy2}" @@ -715,7 +715,7 @@ The unused variable is declared here: Variable ``dx`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_dx` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:5:11:5:13:** ```roc [Move(dx, dy), Move(dx2, dy2), .. as others] => "moved ${Num.toStr dx},${Num.toStr dy} then ${Num.toStr dx2},${Num.toStr dy2}" @@ -727,7 +727,7 @@ The unused variable is declared here: Variable ``dy`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_dy` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:5:15:5:17:** ```roc [Move(dx, dy), Move(dx2, dy2), .. as others] => "moved ${Num.toStr dx},${Num.toStr dy} then ${Num.toStr dx2},${Num.toStr dy2}" @@ -764,7 +764,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``dy`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_dy` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:5:88:5:90:** ```roc [Move(dx, dy), Move(dx2, dy2), .. as others] => "moved ${Num.toStr dx},${Num.toStr dy} then ${Num.toStr dx2},${Num.toStr dy2}" @@ -794,7 +794,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``toStr`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_toStr` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:5:99:5:108:** ```roc [Move(dx, dy), Move(dx2, dy2), .. as others] => "moved ${Num.toStr dx},${Num.toStr dy} then ${Num.toStr dx2},${Num.toStr dy2}" @@ -831,7 +831,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``dy2`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_dy2` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:5:126:5:129:** ```roc [Move(dx, dy), Move(dx2, dy2), .. as others] => "moved ${Num.toStr dx},${Num.toStr dy} then ${Num.toStr dx2},${Num.toStr dy2}" @@ -854,7 +854,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``remaining`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_remaining` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:6:41:6:50:** ```roc [Scroll(amount), Click(x, y), .. as remaining] => "scroll ${Num.toStr amount} then click at ${Num.toStr x},${Num.toStr y}" @@ -866,7 +866,7 @@ The unused variable is declared here: Variable ``amount`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_amount` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:6:13:6:19:** ```roc [Scroll(amount), Click(x, y), .. as remaining] => "scroll ${Num.toStr amount} then click at ${Num.toStr x},${Num.toStr y}" @@ -878,7 +878,7 @@ The unused variable is declared here: Variable ``y`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_y` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:6:31:6:32:** ```roc [Scroll(amount), Click(x, y), .. as remaining] => "scroll ${Num.toStr amount} then click at ${Num.toStr x},${Num.toStr y}" @@ -890,7 +890,7 @@ The unused variable is declared here: Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:6:28:6:29:** ```roc [Scroll(amount), Click(x, y), .. as remaining] => "scroll ${Num.toStr amount} then click at ${Num.toStr x},${Num.toStr y}" @@ -927,7 +927,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:6:109:6:110:** ```roc [Scroll(amount), Click(x, y), .. as remaining] => "scroll ${Num.toStr amount} then click at ${Num.toStr x},${Num.toStr y}" @@ -957,7 +957,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``toStr`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_toStr` to suppress this warning. -The unused variable is declared here: + **complex_list_tags.md:6:114:6:123:** ```roc [Scroll(amount), Click(x, y), .. as remaining] => "scroll ${Num.toStr amount} then click at ${Num.toStr x},${Num.toStr y}" diff --git a/src/snapshots/match_expr/f64_pattern_literal_error.md b/src/snapshots/match_expr/f64_pattern_literal_error.md index a2d70cf273..48ea78f4cc 100644 --- a/src/snapshots/match_expr/f64_pattern_literal_error.md +++ b/src/snapshots/match_expr/f64_pattern_literal_error.md @@ -62,7 +62,7 @@ This pattern contains invalid syntax or uses unsupported features. Variable ``value`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_value` to suppress this warning. -The unused variable is declared here: + **f64_pattern_literal_error.md:4:5:4:10:** ```roc value => "other" diff --git a/src/snapshots/match_expr/guards_1.md b/src/snapshots/match_expr/guards_1.md index 9792c8e567..7d787053f2 100644 --- a/src/snapshots/match_expr/guards_1.md +++ b/src/snapshots/match_expr/guards_1.md @@ -255,7 +255,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **guards_1.md:2:5:2:6:** ```roc x if x > 0 => "positive: ${Num.toStr x}" @@ -285,7 +285,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``toStr`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_toStr` to suppress this warning. -The unused variable is declared here: + **guards_1.md:2:32:2:41:** ```roc x if x > 0 => "positive: ${Num.toStr x}" @@ -315,7 +315,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **guards_1.md:3:5:3:6:** ```roc x if x < 0 => "negative: ${Num.toStr x}" @@ -345,7 +345,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``toStr`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_toStr` to suppress this warning. -The unused variable is declared here: + **guards_1.md:3:32:3:41:** ```roc x if x < 0 => "negative: ${Num.toStr x}" diff --git a/src/snapshots/match_expr/guards_2.md b/src/snapshots/match_expr/guards_2.md index 9a4560d7b7..21d3864e18 100644 --- a/src/snapshots/match_expr/guards_2.md +++ b/src/snapshots/match_expr/guards_2.md @@ -257,7 +257,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``first`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_first` to suppress this warning. -The unused variable is declared here: + **guards_2.md:2:6:2:11:** ```roc [first, .. as rest] if List.len(rest) > 5 => "long list starting with ${Num.toStr first}" @@ -269,7 +269,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **guards_2.md:2:19:2:23:** ```roc [first, .. as rest] if List.len(rest) > 5 => "long list starting with ${Num.toStr first}" @@ -299,7 +299,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``toStr`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_toStr` to suppress this warning. -The unused variable is declared here: + **guards_2.md:2:77:2:86:** ```roc [first, .. as rest] if List.len(rest) > 5 => "long list starting with ${Num.toStr first}" @@ -329,7 +329,7 @@ Check the spelling and make sure you're using a valid Roc operator. Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **guards_2.md:3:6:3:7:** ```roc [x, y] if x == y => "pair of equal values: ${Num.toStr x}" @@ -341,7 +341,7 @@ The unused variable is declared here: Variable ``y`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_y` to suppress this warning. -The unused variable is declared here: + **guards_2.md:3:9:3:10:** ```roc [x, y] if x == y => "pair of equal values: ${Num.toStr x}" @@ -371,7 +371,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``toStr`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_toStr` to suppress this warning. -The unused variable is declared here: + **guards_2.md:3:50:3:59:** ```roc [x, y] if x == y => "pair of equal values: ${Num.toStr x}" diff --git a/src/snapshots/match_expr/list_destructure_variations.md b/src/snapshots/match_expr/list_destructure_variations.md index 8b5ce7bfce..4de467a2b8 100644 --- a/src/snapshots/match_expr/list_destructure_variations.md +++ b/src/snapshots/match_expr/list_destructure_variations.md @@ -35,7 +35,7 @@ match list { Variable ``tail`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_tail` to suppress this warning. -The unused variable is declared here: + **list_destructure_variations.md:5:18:5:22:** ```roc [head, .. as tail] => head @@ -47,7 +47,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **list_destructure_variations.md:6:22:6:26:** ```roc [One, Two, .. as rest] => 3 @@ -59,7 +59,7 @@ The unused variable is declared here: Variable ``more`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_more` to suppress this warning. -The unused variable is declared here: + **list_destructure_variations.md:7:21:7:25:** ```roc [x, y, z, .. as more] => x + y + z diff --git a/src/snapshots/match_expr/list_patterns.md b/src/snapshots/match_expr/list_patterns.md index c61b203b0f..5dc441387c 100644 --- a/src/snapshots/match_expr/list_patterns.md +++ b/src/snapshots/match_expr/list_patterns.md @@ -55,7 +55,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **list_patterns.md:3:15:3:19:** ```roc [first, ..rest] => 0 # invalid rest pattern should error @@ -67,7 +67,7 @@ The unused variable is declared here: Variable ``first`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_first` to suppress this warning. -The unused variable is declared here: + **list_patterns.md:3:6:3:11:** ```roc [first, ..rest] => 0 # invalid rest pattern should error diff --git a/src/snapshots/match_expr/list_patterns_err_multiple_rest.md b/src/snapshots/match_expr/list_patterns_err_multiple_rest.md index 9d4c0fb7cd..9988583def 100644 --- a/src/snapshots/match_expr/list_patterns_err_multiple_rest.md +++ b/src/snapshots/match_expr/list_patterns_err_multiple_rest.md @@ -31,7 +31,7 @@ This pattern contains invalid syntax or uses unsupported features. Variable ``middle`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_middle` to suppress this warning. -The unused variable is declared here: + **list_patterns_err_multiple_rest.md:2:10:2:16:** ```roc [.., middle, ..] => ... # error, multiple rest patterns not allowed diff --git a/src/snapshots/match_expr/list_rest_invalid.md b/src/snapshots/match_expr/list_rest_invalid.md index ea09c9b127..fe104141ee 100644 --- a/src/snapshots/match_expr/list_rest_invalid.md +++ b/src/snapshots/match_expr/list_rest_invalid.md @@ -75,7 +75,7 @@ match items { Variable ``first`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_first` to suppress this warning. -The unused variable is declared here: + **list_rest_invalid.md:2:6:2:11:** ```roc [first, ..rest] => 0 # invalid rest pattern should error @@ -87,7 +87,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **list_rest_invalid.md:2:15:2:19:** ```roc [first, ..rest] => 0 # invalid rest pattern should error @@ -99,7 +99,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **list_rest_invalid.md:3:8:3:12:** ```roc [..rest, last] => 1 # invalid rest pattern should error @@ -111,7 +111,7 @@ The unused variable is declared here: Variable ``last`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_last` to suppress this warning. -The unused variable is declared here: + **list_rest_invalid.md:3:14:3:18:** ```roc [..rest, last] => 1 # invalid rest pattern should error @@ -123,7 +123,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **list_rest_invalid.md:4:11:4:15:** ```roc [x, ..rest, y] => 2 # invalid rest pattern should error @@ -135,7 +135,7 @@ The unused variable is declared here: Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **list_rest_invalid.md:4:6:4:7:** ```roc [x, ..rest, y] => 2 # invalid rest pattern should error @@ -147,7 +147,7 @@ The unused variable is declared here: Variable ``y`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_y` to suppress this warning. -The unused variable is declared here: + **list_rest_invalid.md:4:17:4:18:** ```roc [x, ..rest, y] => 2 # invalid rest pattern should error diff --git a/src/snapshots/match_expr/list_rest_scoping.md b/src/snapshots/match_expr/list_rest_scoping.md index 12af8d9a91..5bf7e5b290 100644 --- a/src/snapshots/match_expr/list_rest_scoping.md +++ b/src/snapshots/match_expr/list_rest_scoping.md @@ -71,7 +71,7 @@ match items { Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **list_rest_scoping.md:2:15:2:19:** ```roc [first, ..rest] => first + 1 @@ -83,7 +83,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **list_rest_scoping.md:3:8:3:12:** ```roc [..rest, last] => last + 2 @@ -95,7 +95,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **list_rest_scoping.md:4:11:4:15:** ```roc [x, ..rest, y] => x + y diff --git a/src/snapshots/match_expr/list_rest_scoping_variables.md b/src/snapshots/match_expr/list_rest_scoping_variables.md index cd9b57d6fa..56b5846598 100644 --- a/src/snapshots/match_expr/list_rest_scoping_variables.md +++ b/src/snapshots/match_expr/list_rest_scoping_variables.md @@ -86,7 +86,7 @@ match data { Variable ``items`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_items` to suppress this warning. -The unused variable is declared here: + **list_rest_scoping_variables.md:2:8:2:13:** ```roc [..items] => 1 @@ -98,7 +98,7 @@ The unused variable is declared here: Variable ``items`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_items` to suppress this warning. -The unused variable is declared here: + **list_rest_scoping_variables.md:3:15:3:20:** ```roc [first, ..items] => first @@ -110,7 +110,7 @@ The unused variable is declared here: Variable ``items`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_items` to suppress this warning. -The unused variable is declared here: + **list_rest_scoping_variables.md:4:8:4:13:** ```roc [..items, last] => last @@ -122,7 +122,7 @@ The unused variable is declared here: Variable ``items`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_items` to suppress this warning. -The unused variable is declared here: + **list_rest_scoping_variables.md:5:15:5:20:** ```roc [first, ..items, last] => first + last diff --git a/src/snapshots/match_expr/middle_rest.md b/src/snapshots/match_expr/middle_rest.md index 6d9e7f814d..5f0d73750b 100644 --- a/src/snapshots/match_expr/middle_rest.md +++ b/src/snapshots/match_expr/middle_rest.md @@ -31,7 +31,7 @@ match items { Variable ``middle`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_middle` to suppress this warning. -The unused variable is declared here: + **middle_rest.md:3:18:3:24:** ```roc [a, b, .. as middle, x, y] => a + b + x + y diff --git a/src/snapshots/match_expr/pattern_as_basic.md b/src/snapshots/match_expr/pattern_as_basic.md index 53b7a9996c..9b5277dffb 100644 --- a/src/snapshots/match_expr/pattern_as_basic.md +++ b/src/snapshots/match_expr/pattern_as_basic.md @@ -17,7 +17,7 @@ UNUSED VARIABLE - pattern_as_basic.md:2:6:2:7 Variable ``y`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_y` to suppress this warning. -The unused variable is declared here: + **pattern_as_basic.md:2:9:2:10:** ```roc (x, y) as point => point @@ -29,7 +29,7 @@ The unused variable is declared here: Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **pattern_as_basic.md:2:6:2:7:** ```roc (x, y) as point => point diff --git a/src/snapshots/match_expr/pattern_as_nested.md b/src/snapshots/match_expr/pattern_as_nested.md index de6e618aec..34ff6ef9c2 100644 --- a/src/snapshots/match_expr/pattern_as_nested.md +++ b/src/snapshots/match_expr/pattern_as_nested.md @@ -29,7 +29,7 @@ match person { Variable ``name`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_name` to suppress this warning. -The unused variable is declared here: + **pattern_as_nested.md:2:7:2:12:** ```roc { name, address: { city } as addr } as fullPerson => (fullPerson, addr, city) diff --git a/src/snapshots/match_expr/tuple_patterns.md b/src/snapshots/match_expr/tuple_patterns.md index 8f82bb6b5c..2a09b09bed 100644 --- a/src/snapshots/match_expr/tuple_patterns.md +++ b/src/snapshots/match_expr/tuple_patterns.md @@ -31,7 +31,7 @@ match coord { Variable ``y`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_y` to suppress this warning. -The unused variable is declared here: + **tuple_patterns.md:5:9:5:10:** ```roc (x, y) => x diff --git a/src/snapshots/match_expr/wildcard_patterns.md b/src/snapshots/match_expr/wildcard_patterns.md index a7d82578a8..50ed4f0a36 100644 --- a/src/snapshots/match_expr/wildcard_patterns.md +++ b/src/snapshots/match_expr/wildcard_patterns.md @@ -30,7 +30,7 @@ match value { Variable ``other`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_other` to suppress this warning. -The unused variable is declared here: + **wildcard_patterns.md:4:5:4:10:** ```roc other => "something else" diff --git a/src/snapshots/nominal/nominal_external_fully_qualified.md b/src/snapshots/nominal/nominal_external_fully_qualified.md index f3ccc2703e..511933acf0 100644 --- a/src/snapshots/nominal/nominal_external_fully_qualified.md +++ b/src/snapshots/nominal/nominal_external_fully_qualified.md @@ -36,7 +36,7 @@ handleResult : MyResultModule.MyResultType(Str, I32) -> Str Variable ``code`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_code` to suppress this warning. -The unused variable is declared here: + **nominal_external_fully_qualified.md:9:41:9:45:** ```roc MyResultModule.MyResultType.Err(code) => "Error: $(code.toStr())" diff --git a/src/snapshots/pattern_f64_overflow.md b/src/snapshots/pattern_f64_overflow.md index ff6e0265e3..0d48daf548 100644 --- a/src/snapshots/pattern_f64_overflow.md +++ b/src/snapshots/pattern_f64_overflow.md @@ -77,7 +77,7 @@ Use a guard: Variable ``value`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_value` to suppress this warning. -The unused variable is declared here: + **pattern_f64_overflow.md:6:5:6:10:** ```roc value => "other" diff --git a/src/snapshots/plume_package/Color.md b/src/snapshots/plume_package/Color.md index 8f16730e28..fc09b69795 100644 --- a/src/snapshots/plume_package/Color.md +++ b/src/snapshots/plume_package/Color.md @@ -266,7 +266,7 @@ Here is the problematic code: Variable ``is_char_in_hex_range`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_is_char_in_hex_range` to suppress this warning. -The unused variable is declared here: + **Color.md:30:5:30:25:** ```roc is_char_in_hex_range = |b| (b >= '0' and b <= '9') or (b >= 'a' and b <= 'f') or (b >= 'A' and b <= 'F') @@ -281,7 +281,7 @@ The body of this lambda expression is not valid. Variable ``str`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_str` to suppress this warning. -The unused variable is declared here: + **Color.md:61:10:61:13:** ```roc named = |str| diff --git a/src/snapshots/records/function_record_parameter_capture.md b/src/snapshots/records/function_record_parameter_capture.md index 14111cbca4..6b0df5a67f 100644 --- a/src/snapshots/records/function_record_parameter_capture.md +++ b/src/snapshots/records/function_record_parameter_capture.md @@ -14,7 +14,7 @@ UNUSED VARIABLE - function_record_parameter_capture.md:1:15:1:20 Variable ``a`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_a` to suppress this warning. -The unused variable is declared here: + **function_record_parameter_capture.md:1:15:1:20:** ```roc |{ name, age, ..a } as person| { greeting: "Hello ${name}", full_record: person, is_adult: age >= 18 } diff --git a/src/snapshots/records/pattern_destructure_nested.md b/src/snapshots/records/pattern_destructure_nested.md index 1589bc8fb3..f6a17eb464 100644 --- a/src/snapshots/records/pattern_destructure_nested.md +++ b/src/snapshots/records/pattern_destructure_nested.md @@ -28,7 +28,7 @@ match person { Variable ``zipCode`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_zipCode` to suppress this warning. -The unused variable is declared here: + **pattern_destructure_nested.md:2:38:2:47:** ```roc { name, address: { street, city, zipCode } } => "${name} lives on ${street} in ${city}" diff --git a/src/snapshots/records/pattern_destructure_simple.md b/src/snapshots/records/pattern_destructure_simple.md index 6a02a6d7eb..b9ab3e4494 100644 --- a/src/snapshots/records/pattern_destructure_simple.md +++ b/src/snapshots/records/pattern_destructure_simple.md @@ -28,7 +28,7 @@ match person { Variable ``age`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_age` to suppress this warning. -The unused variable is declared here: + **pattern_destructure_simple.md:2:13:2:18:** ```roc { name, age } => name diff --git a/src/snapshots/rigid_var_instantiation.md b/src/snapshots/rigid_var_instantiation.md index 49763b327e..41748df874 100644 --- a/src/snapshots/rigid_var_instantiation.md +++ b/src/snapshots/rigid_var_instantiation.md @@ -34,7 +34,7 @@ UNUSED VARIABLE - rigid_var_instantiation.md:16:5:16:8 Variable ``str`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_str` to suppress this warning. -The unused variable is declared here: + **rigid_var_instantiation.md:13:5:13:8:** ```roc str = identity("hello") @@ -46,7 +46,7 @@ The unused variable is declared here: Variable ``num`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_num` to suppress this warning. -The unused variable is declared here: + **rigid_var_instantiation.md:10:5:10:8:** ```roc num = identity(42) @@ -58,7 +58,7 @@ The unused variable is declared here: Variable ``lst`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_lst` to suppress this warning. -The unused variable is declared here: + **rigid_var_instantiation.md:16:5:16:8:** ```roc lst = identity([1, 2, 3]) diff --git a/src/snapshots/rigid_var_no_instantiation_error.md b/src/snapshots/rigid_var_no_instantiation_error.md index 61e3bffa8a..a1d81ac3e8 100644 --- a/src/snapshots/rigid_var_no_instantiation_error.md +++ b/src/snapshots/rigid_var_no_instantiation_error.md @@ -112,7 +112,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``result1`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_result1` to suppress this warning. -The unused variable is declared here: + **rigid_var_no_instantiation_error.md:13:5:13:12:** ```roc result1 = swap((42, "hello")) @@ -124,7 +124,7 @@ The unused variable is declared here: Variable ``result2`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_result2` to suppress this warning. -The unused variable is declared here: + **rigid_var_no_instantiation_error.md:17:5:17:12:** ```roc result2 = swap((Bool.true, [1, 2, 3])) @@ -136,7 +136,7 @@ The unused variable is declared here: Variable ``result3`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_result3` to suppress this warning. -The unused variable is declared here: + **rigid_var_no_instantiation_error.md:21:5:21:12:** ```roc result3 = swap(("foo", "bar")) diff --git a/src/snapshots/syntax_grab_bag.md b/src/snapshots/syntax_grab_bag.md index 87216b38e5..d798996edd 100644 --- a/src/snapshots/syntax_grab_bag.md +++ b/src/snapshots/syntax_grab_bag.md @@ -665,7 +665,7 @@ This pattern contains invalid syntax or uses unsupported features. Variable ``lower`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_lower` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:97:3:97:8:** ```roc lower # After pattern comment @@ -677,7 +677,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:102:19:102:23:** ```roc [1, 2, 3, .. as rest] # After pattern comment @@ -693,7 +693,7 @@ Let us know if you want to help! Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:108:23:108:27:** ```roc [1, 2 | 5, 3, .. as rest] => 123 @@ -709,7 +709,7 @@ Let us know if you want to help! Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:115:6:115:10:** ```roc rest, # After last pattern in list @@ -729,7 +729,7 @@ Let us know if you want to help! Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:121:21:121:29:** ```roc { foo: 1, bar: 2, ..rest } => 12->add(34) @@ -741,7 +741,7 @@ The unused variable is declared here: Variable ``rest`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_rest` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:127:4:128:10:** ```roc .. # After spread operator @@ -761,7 +761,7 @@ Let us know if you want to help! Variable ``b`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_b` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:82:2:82:3:** ```roc b, @@ -895,7 +895,7 @@ Is there an `import` or `exposing` missing up-top? Variable ``multiline_tuple`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_multiline_tuple` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:180:2:180:17:** ```roc multiline_tuple = ( @@ -907,7 +907,7 @@ The unused variable is declared here: Variable ``record`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_record` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:178:2:178:8:** ```roc record = { foo: 123, bar: "Hello", baz: tag, qux: Ok(world), punned } @@ -919,7 +919,7 @@ The unused variable is declared here: Variable ``tag_with_payload`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_tag_with_payload` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:164:2:164:18:** ```roc tag_with_payload = Ok(number) @@ -931,7 +931,7 @@ The unused variable is declared here: Variable ``list`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_list` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:166:2:166:6:** ```roc list = [ @@ -943,7 +943,7 @@ The unused variable is declared here: Variable ``bin_op_result`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_bin_op_result` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:188:2:188:15:** ```roc bin_op_result = Err(foo) ?? 12 > 5 * 5 or 13 + 2 < 5 and 10 - 1 >= 16 or 12 <= 3 / 5 @@ -955,7 +955,7 @@ The unused variable is declared here: Variable ``static_dispatch_style`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_static_dispatch_style` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:189:2:189:23:** ```roc static_dispatch_style = some_fn(arg1)?.static_dispatch_method()?.next_static_dispatch_method()?.record_field? @@ -967,7 +967,7 @@ The unused variable is declared here: Variable ``interpolated`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_interpolated` to suppress this warning. -The unused variable is declared here: + **syntax_grab_bag.md:165:2:165:14:** ```roc interpolated = "Hello, ${world}" diff --git a/src/snapshots/test_exact_pattern_crash.md b/src/snapshots/test_exact_pattern_crash.md index 79563d4767..76e2c5be86 100644 --- a/src/snapshots/test_exact_pattern_crash.md +++ b/src/snapshots/test_exact_pattern_crash.md @@ -40,7 +40,7 @@ TYPE MISMATCH - test_exact_pattern_crash.md:23:10:23:18 Variable ``p1`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_p1` to suppress this warning. -The unused variable is declared here: + **test_exact_pattern_crash.md:19:5:19:7:** ```roc p1 = swap_pair((1, 2)) diff --git a/src/snapshots/type_alias_decl.md b/src/snapshots/type_alias_decl.md index cbef341bf2..fc642010af 100644 --- a/src/snapshots/type_alias_decl.md +++ b/src/snapshots/type_alias_decl.md @@ -295,7 +295,7 @@ app [main!] { pf: platform "../basic-cli/main.roc" } Variable ``color`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_color` to suppress this warning. -The unused variable is declared here: + **type_alias_decl.md:36:5:36:10:** ```roc color = Red @@ -307,7 +307,7 @@ The unused variable is declared here: Variable ``person`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_person` to suppress this warning. -The unused variable is declared here: + **type_alias_decl.md:33:5:33:11:** ```roc person = { name: "Alice", age: 30 } diff --git a/src/snapshots/type_annotation_basic.md b/src/snapshots/type_annotation_basic.md index 14e7b8c2bf..a4e3ff8c5c 100644 --- a/src/snapshots/type_annotation_basic.md +++ b/src/snapshots/type_annotation_basic.md @@ -40,7 +40,7 @@ UNUSED VARIABLE - type_annotation_basic.md:21:5:21:9 Variable ``pair`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_pair` to suppress this warning. -The unused variable is declared here: + **type_annotation_basic.md:21:5:21:9:** ```roc pair = combine(num, text) diff --git a/src/snapshots/type_app_complex_nested.md b/src/snapshots/type_app_complex_nested.md index 9a0c840b49..f9861a7901 100644 --- a/src/snapshots/type_app_complex_nested.md +++ b/src/snapshots/type_app_complex_nested.md @@ -95,7 +95,7 @@ processComplex : Result(List(Maybe(a)), Dict(Str, Error(b))) -> List(a) Variable ``maybeList`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_maybeList` to suppress this warning. -The unused variable is declared here: + **type_app_complex_nested.md:7:12:7:21:** ```roc Ok(maybeList) => [] diff --git a/src/snapshots/type_shadowing_across_scopes.md b/src/snapshots/type_shadowing_across_scopes.md index db63bbd557..b838d65a76 100644 --- a/src/snapshots/type_shadowing_across_scopes.md +++ b/src/snapshots/type_shadowing_across_scopes.md @@ -101,7 +101,7 @@ This type annotation is malformed or contains invalid syntax. Variable ``data`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_data` to suppress this warning. -The unused variable is declared here: + **type_shadowing_across_scopes.md:6:16:6:20:** ```roc processData = |data| diff --git a/src/snapshots/type_tag_union_basic.md b/src/snapshots/type_tag_union_basic.md index eab7485811..0b2eefaf5b 100644 --- a/src/snapshots/type_tag_union_basic.md +++ b/src/snapshots/type_tag_union_basic.md @@ -19,7 +19,7 @@ UNUSED VARIABLE - type_tag_union_basic.md:4:12:4:17 Variable ``maybe`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_maybe` to suppress this warning. -The unused variable is declared here: + **type_tag_union_basic.md:4:12:4:17:** ```roc process = |maybe| "result" diff --git a/src/snapshots/type_undeclared_usage.md b/src/snapshots/type_undeclared_usage.md index 7d514541fe..db723e3fbd 100644 --- a/src/snapshots/type_undeclared_usage.md +++ b/src/snapshots/type_undeclared_usage.md @@ -47,7 +47,7 @@ processValue : UndeclaredResult -> Str Variable ``value`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_value` to suppress this warning. -The unused variable is declared here: + **type_undeclared_usage.md:6:17:6:22:** ```roc processValue = |value| { diff --git a/src/snapshots/unused_vars_block.md b/src/snapshots/unused_vars_block.md index 26679d7d49..b70333c442 100644 --- a/src/snapshots/unused_vars_block.md +++ b/src/snapshots/unused_vars_block.md @@ -33,7 +33,7 @@ UNUSED VARIABLE - unused_vars_block.md:11:5:11:19 Variable ``unused_var`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_unused_var` to suppress this warning. -The unused variable is declared here: + **unused_vars_block.md:5:5:5:15:** ```roc unused_var = 42 @@ -45,7 +45,7 @@ The unused variable is declared here: Variable ``another_unused`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_another_unused` to suppress this warning. -The unused variable is declared here: + **unused_vars_block.md:11:5:11:19:** ```roc another_unused = "hello" diff --git a/src/snapshots/unused_vars_simple.md b/src/snapshots/unused_vars_simple.md index e82b2e4562..c527c1fda9 100644 --- a/src/snapshots/unused_vars_simple.md +++ b/src/snapshots/unused_vars_simple.md @@ -35,7 +35,7 @@ UNDERSCORE VARIABLE USED - unused_vars_simple.md:7:28:7:34 Variable ``x`` is not used anywhere in your code. If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. -The unused variable is declared here: + **unused_vars_simple.md:4:19:4:20:** ```roc unused_regular = |x| 42 @@ -47,7 +47,7 @@ unused_regular = |x| 42 Variable ``_value`` is prefixed with an underscore but is actually used. Variables prefixed with `_` are intended to be unused. Remove the underscore prefix: `value`. -The underscore variable is declared here: + **unused_vars_simple.md:7:28:7:34:** ```roc used_underscore = |_value| _value