diff --git a/src/canonicalize/Mod.zig b/src/canonicalize/Mod.zig index b2e86a808f3..4beba07e7f3 100644 --- a/src/canonicalize/Mod.zig +++ b/src/canonicalize/Mod.zig @@ -6228,6 +6228,13 @@ fn checkUsedUnderscoreVariable( } fn checkScopeForUnusedVariables(self: *Self, scope: *const Scope) std.mem.Allocator.Error!void { + // Define the type for unused variables + const UnusedVar = struct { ident: base.Ident.Idx, region: Region }; + + // Collect all unused variables first so we can sort them + var unused_vars = std.ArrayList(UnusedVar).init(self.env.gpa); + defer unused_vars.deinit(); + // Iterate through all identifiers in this scope var iterator = scope.idents.iterator(); while (iterator.next()) |entry| { @@ -6247,10 +6254,26 @@ fn checkScopeForUnusedVariables(self: *Self, scope: *const Scope) std.mem.Alloca // Get the region for this pattern to provide good error location const region = self.env.store.getPatternRegion(pattern_idx); - // Report unused variable - try self.env.pushDiagnostic(Diagnostic{ .unused_variable = .{ + // Collect unused variable for sorting + try unused_vars.append(.{ .ident = ident_idx, .region = region, + }); + } + + // Sort unused variables by region (earlier in file first) + std.mem.sort(UnusedVar, unused_vars.items, {}, struct { + fn lessThan(_: void, a: UnusedVar, b: UnusedVar) bool { + // Compare by start offset (position in file) + return a.region.start.offset < b.region.start.offset; + } + }.lessThan); + + // Report unused variables in sorted order + for (unused_vars.items) |unused| { + try self.env.pushDiagnostic(Diagnostic{ .unused_variable = .{ + .ident = unused.ident, + .region = unused.region, } }); } } @@ -8679,3 +8702,79 @@ test "hex literal parsing logic integration" { try std.testing.expectEqual(tc.expected_value, u128_val); } } + +test "unused variables are sorted by region" { + const gpa = std.testing.allocator; + + // Create a test program with unused variables in non-alphabetical order + const source = + \\app [main!] { pf: platform "../basic-cli/main.roc" } + \\ + \\func = |_| { + \\ zebra = 5 # Line 3 - should be reported first + \\ apple = 10 # Line 4 - should be reported second + \\ monkey = 15 # Line 5 - should be reported third + \\ used = 20 # Line 6 - this one is used + \\ used + \\} + \\ + \\main! = |_| func({}) + ; + + var ctx = try ScopeTestContext.init(gpa); + defer ctx.deinit(); + + // Parse the source + const ast = try parse.AST.parseFromStr(gpa, source, "test.roc", &ctx.module_env.string_interner); + defer ast.deinit(); + + // Canonicalize the AST + const parsed_module = ast.parsed_module; + var self = try Self.initFromAST(parsed_module, &ctx.module_env, source); + try self.canonicalizeModule(); + defer self.deinit(); + + // Check that we have unused variable diagnostics + var unused_var_diagnostics = std.ArrayList(struct { + ident: base.Ident.Idx, + region: Region, + }).init(gpa); + defer unused_var_diagnostics.deinit(); + + // Collect all unused variable diagnostics + for (ctx.module_env.diagnostics.items) |diagnostic| { + switch (diagnostic) { + .unused_variable => |data| { + try unused_var_diagnostics.append(.{ + .ident = data.ident, + .region = data.region, + }); + }, + else => continue, + } + } + + // We should have exactly 3 unused variables (zebra, apple, monkey) + try std.testing.expectEqual(@as(usize, 3), unused_var_diagnostics.items.len); + + // Check that they are sorted by region (line number) + // The source positions should be in increasing order + var prev_offset: u32 = 0; + for (unused_var_diagnostics.items) |diagnostic| { + const current_offset = diagnostic.region.start.offset; + + // Each unused variable should appear after the previous one in the source + try std.testing.expect(current_offset > prev_offset); + prev_offset = current_offset; + + // Also verify the names are in the expected order (zebra, apple, monkey) + const ident_text = ctx.module_env.idents.getText(diagnostic.ident); + if (unused_var_diagnostics.items[0].ident.idx == diagnostic.ident.idx) { + try std.testing.expectEqualStrings("zebra", ident_text); + } else if (unused_var_diagnostics.items[1].ident.idx == diagnostic.ident.idx) { + try std.testing.expectEqualStrings("apple", ident_text); + } else if (unused_var_diagnostics.items[2].ident.idx == diagnostic.ident.idx) { + try std.testing.expectEqualStrings("monkey", ident_text); + } + } +} diff --git a/src/snapshots/crash_and_ellipsis_test.md b/src/snapshots/crash_and_ellipsis_test.md index 7a94d7dddbf..9f733a2cac9 100644 --- a/src/snapshots/crash_and_ellipsis_test.md +++ b/src/snapshots/crash_and_ellipsis_test.md @@ -31,44 +31,44 @@ main! = |_| { } ~~~ # EXPECTED +UNUSED VARIABLE - crash_and_ellipsis_test.md:20:5:20:12 UNUSED VARIABLE - crash_and_ellipsis_test.md:21:5:21:12 UNUSED VARIABLE - crash_and_ellipsis_test.md:22:5:22:12 -UNUSED VARIABLE - crash_and_ellipsis_test.md:20:5:20:12 TYPE MISMATCH - crash_and_ellipsis_test.md:8:20:8:23 TYPE MISMATCH - crash_and_ellipsis_test.md:14:26:14:29 # PROBLEMS **UNUSED VARIABLE** -Variable `result2` is not used anywhere in your code. +Variable `result1` 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. +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:21:5:21:12:** +**crash_and_ellipsis_test.md:20:5:20:12:** ```roc - result2 = testCrash(42) + result1 = testEllipsis(42) ``` ^^^^^^^ **UNUSED VARIABLE** -Variable `result3` is not used anywhere in your code. +Variable `result2` 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. +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:22:5:22:12:** +**crash_and_ellipsis_test.md:21:5:21:12:** ```roc - result3 = testCrashSimple(42) + result2 = testCrash(42) ``` ^^^^^^^ **UNUSED VARIABLE** -Variable `result1` is not used anywhere in your code. +Variable `result3` 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. +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:20:5:20:12:** +**crash_and_ellipsis_test.md:22:5:22:12:** ```roc - result1 = testEllipsis(42) + result3 = testCrashSimple(42) ``` ^^^^^^^ diff --git a/src/snapshots/expr/tuple_comprehensive.md b/src/snapshots/expr/tuple_comprehensive.md index cfd0601976d..45696bf0edb 100644 --- a/src/snapshots/expr/tuple_comprehensive.md +++ b/src/snapshots/expr/tuple_comprehensive.md @@ -27,13 +27,13 @@ type=expr ~~~ # EXPECTED EMPTY TUPLE NOT ALLOWED - tuple_comprehensive.md:9:10:9:12 +UNUSED VARIABLE - tuple_comprehensive.md:10:2:10:8 UNUSED VARIABLE - tuple_comprehensive.md:11:2:11:6 UNUSED VARIABLE - tuple_comprehensive.md:12:2:12:8 -UNUSED VARIABLE - tuple_comprehensive.md:10:2:10:8 UNUSED VARIABLE - tuple_comprehensive.md:13:2:13:8 +UNUSED VARIABLE - tuple_comprehensive.md:14:2:14:7 UNUSED VARIABLE - tuple_comprehensive.md:15:2:15:11 UNUSED VARIABLE - tuple_comprehensive.md:16:2:16:13 -UNUSED VARIABLE - tuple_comprehensive.md:14:2:14:7 # PROBLEMS **EMPTY TUPLE NOT ALLOWED** I am part way through parsing this tuple, but it is empty: @@ -45,6 +45,18 @@ I am part way through parsing this tuple, but it is empty: If you want to represent nothing, try using an empty record: `{}`. +**UNUSED VARIABLE** +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) +``` + ^^^^^^ + + **UNUSED VARIABLE** Variable `pair` is not used anywhere in your code. @@ -70,27 +82,27 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `single` is not used anywhere in your code. +Variable `nested` 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. +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:10:2:10:8:** +**tuple_comprehensive.md:13:2:13:8:** ```roc - single = (42) + nested = ((1, 2), (3, 4)) ``` ^^^^^^ **UNUSED VARIABLE** -Variable `nested` is not used anywhere in your code. +Variable `mixed` 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. +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:13:2:13:8:** +**tuple_comprehensive.md:14:2:14:7:** ```roc - nested = ((1, 2), (3, 4)) + mixed = (add_one(5), "world", [1, 2, 3]) ``` - ^^^^^^ + ^^^^^ **UNUSED VARIABLE** @@ -117,18 +129,6 @@ The unused variable is declared here: ^^^^^^^^^^^ -**UNUSED VARIABLE** -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]) -``` - ^^^^^ - - # TOKENS ~~~zig OpenCurly(1:1-1:2), diff --git a/src/snapshots/expr/tuple_patterns.md b/src/snapshots/expr/tuple_patterns.md index 3336782a748..7deef6d4f5b 100644 --- a/src/snapshots/expr/tuple_patterns.md +++ b/src/snapshots/expr/tuple_patterns.md @@ -26,31 +26,43 @@ type=expr } ~~~ # EXPECTED -UNUSED VARIABLE - tuple_patterns.md:13:12:13:18 +UNUSED VARIABLE - tuple_patterns.md:4:6:4:7 +UNUSED VARIABLE - tuple_patterns.md:4:9:4:10 UNUSED VARIABLE - tuple_patterns.md:7:7:7:8 -UNUSED VARIABLE - tuple_patterns.md:16:6:16:10 +UNUSED VARIABLE - tuple_patterns.md:7:10:7:11 UNUSED VARIABLE - tuple_patterns.md:7:15:7:16 +UNUSED VARIABLE - tuple_patterns.md:7:18:7:19 +UNUSED VARIABLE - tuple_patterns.md:10:6:10:11 UNUSED VARIABLE - tuple_patterns.md:10:13:10:19 +UNUSED VARIABLE - tuple_patterns.md:10:21:10:26 UNUSED VARIABLE - tuple_patterns.md:13:6:13:10 -UNUSED VARIABLE - tuple_patterns.md:7:18:7:19 +UNUSED VARIABLE - tuple_patterns.md:13:12:13:18 UNUSED VARIABLE - tuple_patterns.md:13:20:13:27 -UNUSED VARIABLE - tuple_patterns.md:10:6:10:11 +UNUSED VARIABLE - tuple_patterns.md:16:6:16:10 UNUSED VARIABLE - tuple_patterns.md:16:12:16:17 -UNUSED VARIABLE - tuple_patterns.md:10:21:10:26 -UNUSED VARIABLE - tuple_patterns.md:4:6:4:7 -UNUSED VARIABLE - tuple_patterns.md:4:9:4:10 -UNUSED VARIABLE - tuple_patterns.md:7:10:7:11 # PROBLEMS **UNUSED VARIABLE** -Variable `string` is not used anywhere in your code. +Variable `x` is not used anywhere in your code. -If you don't need this variable, prefix it with an underscore like `_string` to suppress this warning. +If you don't need this variable, prefix it with an underscore like `_x` to suppress this warning. The unused variable is declared here: -**tuple_patterns.md:13:12:13:18:** +**tuple_patterns.md:4:6:4:7:** ```roc - (name, string, boolean) = ("Alice", "fixed", True) + (x, y) = (1, 2) ``` - ^^^^^^ + ^ + + +**UNUSED VARIABLE** +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:4:9:4:10:** +```roc + (x, y) = (1, 2) +``` + ^ **UNUSED VARIABLE** @@ -66,15 +78,15 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `list` is not used anywhere in your code. +Variable `b` 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. +If you don't need this variable, prefix it with an underscore like `_b` to suppress this warning. The unused variable is declared here: -**tuple_patterns.md:16:6:16:10:** +**tuple_patterns.md:7:10:7:11:** ```roc - (list, hello) = ([1, 2, 3], "hello") + ((a, b), (c, d)) = ((10, 20), (30, 40)) ``` - ^^^^ + ^ **UNUSED VARIABLE** @@ -89,30 +101,6 @@ The unused variable is declared here: ^ -**UNUSED VARIABLE** -Variable `second` is not used anywhere in your code. - -If you don't need this variable, prefix it with an underscore like `_second` to suppress this warning. -The unused variable is declared here: -**tuple_patterns.md:10:13:10:19:** -```roc - (first, second, third) = (100, 42, 200) -``` - ^^^^^^ - - -**UNUSED VARIABLE** -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: -**tuple_patterns.md:13:6:13:10:** -```roc - (name, string, boolean) = ("Alice", "fixed", True) -``` - ^^^^ - - **UNUSED VARIABLE** Variable `d` is not used anywhere in your code. @@ -125,18 +113,6 @@ The unused variable is declared here: ^ -**UNUSED VARIABLE** -Variable `boolean` is not used anywhere in your code. - -If you don't need this variable, prefix it with an underscore like `_boolean` to suppress this warning. -The unused variable is declared here: -**tuple_patterns.md:13:20:13:27:** -```roc - (name, string, boolean) = ("Alice", "fixed", True) -``` - ^^^^^^^ - - **UNUSED VARIABLE** Variable `first` is not used anywhere in your code. @@ -150,15 +126,15 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `hello` is not used anywhere in your code. +Variable `second` is not used anywhere in your code. -If you don't need this variable, prefix it with an underscore like `_hello` to suppress this warning. +If you don't need this variable, prefix it with an underscore like `_second` to suppress this warning. The unused variable is declared here: -**tuple_patterns.md:16:12:16:17:** +**tuple_patterns.md:10:13:10:19:** ```roc - (list, hello) = ([1, 2, 3], "hello") + (first, second, third) = (100, 42, 200) ``` - ^^^^^ + ^^^^^^ **UNUSED VARIABLE** @@ -174,39 +150,63 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `x` is not used anywhere in your code. +Variable `name` 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. +If you don't need this variable, prefix it with an underscore like `_name` to suppress this warning. The unused variable is declared here: -**tuple_patterns.md:4:6:4:7:** +**tuple_patterns.md:13:6:13:10:** ```roc - (x, y) = (1, 2) + (name, string, boolean) = ("Alice", "fixed", True) ``` - ^ + ^^^^ **UNUSED VARIABLE** -Variable `y` is not used anywhere in your code. +Variable `string` 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. +If you don't need this variable, prefix it with an underscore like `_string` to suppress this warning. The unused variable is declared here: -**tuple_patterns.md:4:9:4:10:** +**tuple_patterns.md:13:12:13:18:** ```roc - (x, y) = (1, 2) + (name, string, boolean) = ("Alice", "fixed", True) ``` - ^ + ^^^^^^ **UNUSED VARIABLE** -Variable `b` is not used anywhere in your code. +Variable `boolean` 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. +If you don't need this variable, prefix it with an underscore like `_boolean` to suppress this warning. The unused variable is declared here: -**tuple_patterns.md:7:10:7:11:** +**tuple_patterns.md:13:20:13:27:** ```roc - ((a, b), (c, d)) = ((10, 20), (30, 40)) + (name, string, boolean) = ("Alice", "fixed", True) ``` - ^ + ^^^^^^^ + + +**UNUSED VARIABLE** +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: +**tuple_patterns.md:16:6:16:10:** +```roc + (list, hello) = ([1, 2, 3], "hello") +``` + ^^^^ + + +**UNUSED VARIABLE** +Variable `hello` is not used anywhere in your code. + +If you don't need this variable, prefix it with an underscore like `_hello` to suppress this warning. +The unused variable is declared here: +**tuple_patterns.md:16:12:16:17:** +```roc + (list, hello) = ([1, 2, 3], "hello") +``` + ^^^^^ # TOKENS diff --git a/src/snapshots/formatting/multiline/everything.md b/src/snapshots/formatting/multiline/everything.md index 97e49e27f26..588e7873288 100644 --- a/src/snapshots/formatting/multiline/everything.md +++ b/src/snapshots/formatting/multiline/everything.md @@ -125,11 +125,11 @@ UNUSED VARIABLE - everything.md:90:5:90:6 UNUSED VARIABLE - everything.md:95:4:95:5 UNUSED VARIABLE - everything.md:100:5:100:6 UNUSED VARIABLE - everything.md:106:5:106:6 -UNUSED VARIABLE - everything.md:81:2:81:4 UNUSED VARIABLE - everything.md:61:2:61:4 UNUSED VARIABLE - everything.md:69:2:69:4 -UNUSED VARIABLE - everything.md:77:2:77:4 UNUSED VARIABLE - everything.md:73:2:73:4 +UNUSED VARIABLE - everything.md:77:2:77:4 +UNUSED VARIABLE - everything.md:81:2:81:4 # PROBLEMS **WHERE CLAUSE NOT ALLOWED IN TYPE DECLARATION** You cannot define a `where` clause inside a type declaration. @@ -243,18 +243,6 @@ The unused variable is declared here: ^ -**UNUSED VARIABLE** -Variable `h5` is not used anywhere in your code. - -If you don't need this variable, prefix it with an underscore like `_h5` to suppress this warning. -The unused variable is declared here: -**everything.md:81:2:81:4:** -```roc - h5 = ( -``` - ^^ - - **UNUSED VARIABLE** Variable `h1` is not used anywhere in your code. @@ -279,6 +267,18 @@ The unused variable is declared here: ^^ +**UNUSED VARIABLE** +Variable `h3` is not used anywhere in your code. + +If you don't need this variable, prefix it with an underscore like `_h3` to suppress this warning. +The unused variable is declared here: +**everything.md:73:2:73:4:** +```roc + h3 = A( +``` + ^^ + + **UNUSED VARIABLE** Variable `h4` is not used anywhere in your code. @@ -292,13 +292,13 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `h3` is not used anywhere in your code. +Variable `h5` is not used anywhere in your code. -If you don't need this variable, prefix it with an underscore like `_h3` to suppress this warning. +If you don't need this variable, prefix it with an underscore like `_h5` to suppress this warning. The unused variable is declared here: -**everything.md:73:2:73:4:** +**everything.md:81:2:81:4:** ```roc - h3 = A( + h5 = ( ``` ^^ diff --git a/src/snapshots/formatting/multiline_without_comma/everything.md b/src/snapshots/formatting/multiline_without_comma/everything.md index 069748bb12e..16aa8e1fee0 100644 --- a/src/snapshots/formatting/multiline_without_comma/everything.md +++ b/src/snapshots/formatting/multiline_without_comma/everything.md @@ -125,11 +125,11 @@ UNUSED VARIABLE - everything.md:90:5:90:6 UNUSED VARIABLE - everything.md:95:4:95:5 UNUSED VARIABLE - everything.md:100:5:100:6 UNUSED VARIABLE - everything.md:106:5:106:6 -UNUSED VARIABLE - everything.md:81:2:81:4 UNUSED VARIABLE - everything.md:61:2:61:4 UNUSED VARIABLE - everything.md:69:2:69:4 -UNUSED VARIABLE - everything.md:77:2:77:4 UNUSED VARIABLE - everything.md:73:2:73:4 +UNUSED VARIABLE - everything.md:77:2:77:4 +UNUSED VARIABLE - everything.md:81:2:81:4 # PROBLEMS **WHERE CLAUSE NOT ALLOWED IN TYPE DECLARATION** You cannot define a `where` clause inside a type declaration. @@ -243,18 +243,6 @@ The unused variable is declared here: ^ -**UNUSED VARIABLE** -Variable `h5` is not used anywhere in your code. - -If you don't need this variable, prefix it with an underscore like `_h5` to suppress this warning. -The unused variable is declared here: -**everything.md:81:2:81:4:** -```roc - h5 = ( -``` - ^^ - - **UNUSED VARIABLE** Variable `h1` is not used anywhere in your code. @@ -279,6 +267,18 @@ The unused variable is declared here: ^^ +**UNUSED VARIABLE** +Variable `h3` is not used anywhere in your code. + +If you don't need this variable, prefix it with an underscore like `_h3` to suppress this warning. +The unused variable is declared here: +**everything.md:73:2:73:4:** +```roc + h3 = A( +``` + ^^ + + **UNUSED VARIABLE** Variable `h4` is not used anywhere in your code. @@ -292,13 +292,13 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `h3` is not used anywhere in your code. +Variable `h5` is not used anywhere in your code. -If you don't need this variable, prefix it with an underscore like `_h3` to suppress this warning. +If you don't need this variable, prefix it with an underscore like `_h5` to suppress this warning. The unused variable is declared here: -**everything.md:73:2:73:4:** +**everything.md:81:2:81:4:** ```roc - h3 = A( + h5 = ( ``` ^^ diff --git a/src/snapshots/formatting/singleline/everything.md b/src/snapshots/formatting/singleline/everything.md index 9afa2f568e9..aa0dae440d9 100644 --- a/src/snapshots/formatting/singleline/everything.md +++ b/src/snapshots/formatting/singleline/everything.md @@ -46,11 +46,11 @@ UNUSED VARIABLE - everything.md:26:10:26:11 UNUSED VARIABLE - everything.md:27:9:27:10 UNUSED VARIABLE - everything.md:28:11:28:12 UNUSED VARIABLE - everything.md:29:10:29:11 -UNUSED VARIABLE - everything.md:23:2:23:4 UNUSED VARIABLE - everything.md:19:2:19:4 UNUSED VARIABLE - everything.md:20:2:20:4 -UNUSED VARIABLE - everything.md:22:2:22:4 UNUSED VARIABLE - everything.md:21:2:21:4 +UNUSED VARIABLE - everything.md:22:2:22:4 +UNUSED VARIABLE - everything.md:23:2:23:4 # PROBLEMS **WHERE CLAUSE NOT ALLOWED IN TYPE DECLARATION** You cannot define a `where` clause inside a type declaration. @@ -144,18 +144,6 @@ The unused variable is declared here: ^ -**UNUSED VARIABLE** -Variable `h5` is not used anywhere in your code. - -If you don't need this variable, prefix it with an underscore like `_h5` to suppress this warning. -The unused variable is declared here: -**everything.md:23:2:23:4:** -```roc - h5 = (x, y) -``` - ^^ - - **UNUSED VARIABLE** Variable `h1` is not used anywhere in your code. @@ -180,6 +168,18 @@ The unused variable is declared here: ^^ +**UNUSED VARIABLE** +Variable `h3` is not used anywhere in your code. + +If you don't need this variable, prefix it with an underscore like `_h3` to suppress this warning. +The unused variable is declared here: +**everything.md:21:2:21:4:** +```roc + h3 = A(x, y) +``` + ^^ + + **UNUSED VARIABLE** Variable `h4` is not used anywhere in your code. @@ -193,13 +193,13 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `h3` is not used anywhere in your code. +Variable `h5` is not used anywhere in your code. -If you don't need this variable, prefix it with an underscore like `_h3` to suppress this warning. +If you don't need this variable, prefix it with an underscore like `_h5` to suppress this warning. The unused variable is declared here: -**everything.md:21:2:21:4:** +**everything.md:23:2:23:4:** ```roc - h3 = A(x, y) + h5 = (x, y) ``` ^^ diff --git a/src/snapshots/formatting/singleline_with_comma/everything.md b/src/snapshots/formatting/singleline_with_comma/everything.md index 9d867a39882..95dcdde3f7f 100644 --- a/src/snapshots/formatting/singleline_with_comma/everything.md +++ b/src/snapshots/formatting/singleline_with_comma/everything.md @@ -46,11 +46,11 @@ UNUSED VARIABLE - everything.md:26:10:26:11 UNUSED VARIABLE - everything.md:27:9:27:10 UNUSED VARIABLE - everything.md:28:11:28:12 UNUSED VARIABLE - everything.md:29:10:29:11 -UNUSED VARIABLE - everything.md:23:2:23:4 UNUSED VARIABLE - everything.md:19:2:19:4 UNUSED VARIABLE - everything.md:20:2:20:4 -UNUSED VARIABLE - everything.md:22:2:22:4 UNUSED VARIABLE - everything.md:21:2:21:4 +UNUSED VARIABLE - everything.md:22:2:22:4 +UNUSED VARIABLE - everything.md:23:2:23:4 # PROBLEMS **WHERE CLAUSE NOT ALLOWED IN TYPE DECLARATION** You cannot define a `where` clause inside a type declaration. @@ -144,18 +144,6 @@ The unused variable is declared here: ^ -**UNUSED VARIABLE** -Variable `h5` is not used anywhere in your code. - -If you don't need this variable, prefix it with an underscore like `_h5` to suppress this warning. -The unused variable is declared here: -**everything.md:23:2:23:4:** -```roc - h5 = (x, y,) -``` - ^^ - - **UNUSED VARIABLE** Variable `h1` is not used anywhere in your code. @@ -180,6 +168,18 @@ The unused variable is declared here: ^^ +**UNUSED VARIABLE** +Variable `h3` is not used anywhere in your code. + +If you don't need this variable, prefix it with an underscore like `_h3` to suppress this warning. +The unused variable is declared here: +**everything.md:21:2:21:4:** +```roc + h3 = A(x, y,) +``` + ^^ + + **UNUSED VARIABLE** Variable `h4` is not used anywhere in your code. @@ -193,13 +193,13 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `h3` is not used anywhere in your code. +Variable `h5` is not used anywhere in your code. -If you don't need this variable, prefix it with an underscore like `_h3` to suppress this warning. +If you don't need this variable, prefix it with an underscore like `_h5` to suppress this warning. The unused variable is declared here: -**everything.md:21:2:21:4:** +**everything.md:23:2:23:4:** ```roc - h3 = A(x, y,) + h5 = (x, y,) ``` ^^ diff --git a/src/snapshots/fuzz_crash/fuzz_crash_019.md b/src/snapshots/fuzz_crash/fuzz_crash_019.md index 3f30770ed6b..798577e7ab3 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_019.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_019.md @@ -178,8 +178,8 @@ UNDEFINED VARIABLE - fuzz_crash_019.md:105:2:105:3 NOT IMPLEMENTED - :0:0:0:0 UNDEFINED VARIABLE - fuzz_crash_019.md:108:4:108:5 UNDEFINED VARIABLE - fuzz_crash_019.md:108:6:108:8 -UNUSED VARIABLE - fuzz_crash_019.md:87:2:87:3 UNUSED VARIABLE - fuzz_crash_019.md:76:2:76:3 +UNUSED VARIABLE - fuzz_crash_019.md:87:2:87:3 UNUSED VARIABLE - fuzz_crash_019.md:96:2:96:4 UNDECLARED TYPE - fuzz_crash_019.md:116:5:116:6 UNDEFINED VARIABLE - fuzz_crash_019.md:119:2:119:5 @@ -752,25 +752,25 @@ Is there an `import` or `exposing` missing up-top? **UNUSED VARIABLE** -Variable `i` is not used anywhere in your code. +Variable `w` 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. +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:87:2:87:3:** +**fuzz_crash_019.md:76:2:76:3:** ```roc - i= "H, ${d}" + w = "d" ``` ^ **UNUSED VARIABLE** -Variable `w` is not used anywhere in your code. +Variable `i` 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. +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:76:2:76:3:** +**fuzz_crash_019.md:87:2:87:3:** ```roc - w = "d" + i= "H, ${d}" ``` ^ diff --git a/src/snapshots/fuzz_crash/fuzz_crash_020.md b/src/snapshots/fuzz_crash/fuzz_crash_020.md index 94b68c771e2..5fa2ce3a465 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_020.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_020.md @@ -179,9 +179,9 @@ UNDEFINED VARIABLE - fuzz_crash_020.md:105:2:105:3 NOT IMPLEMENTED - :0:0:0:0 UNDEFINED VARIABLE - fuzz_crash_020.md:108:4:108:5 UNDEFINED VARIABLE - fuzz_crash_020.md:108:6:108:8 +UNUSED VARIABLE - fuzz_crash_020.md:76:2:76:3 UNUSED VARIABLE - fuzz_crash_020.md:87:2:87:3 UNUSED VARIABLE - fuzz_crash_020.md:96:2:96:4 -UNUSED VARIABLE - fuzz_crash_020.md:76:2:76:3 UNDECLARED TYPE - fuzz_crash_020.md:116:5:116:6 UNDEFINED VARIABLE - fuzz_crash_020.md:119:2:119:5 UNDEFINED VARIABLE - fuzz_crash_020.md:120:1:120:2 @@ -762,6 +762,18 @@ Is there an `import` or `exposing` missing up-top? ^^ +**UNUSED VARIABLE** +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" +``` + ^ + + **UNUSED VARIABLE** Variable `i` is not used anywhere in your code. @@ -786,18 +798,6 @@ The unused variable is declared here: ^^ -**UNUSED VARIABLE** -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" -``` - ^ - - **UNDECLARED TYPE** The type _V_ is not declared in this scope. diff --git a/src/snapshots/fuzz_crash/fuzz_crash_023.md b/src/snapshots/fuzz_crash/fuzz_crash_023.md index 3951aae3e92..ab9813a75e3 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_023.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_023.md @@ -264,13 +264,13 @@ UNDEFINED VARIABLE - fuzz_crash_023.md:188:22:188:25 NOT IMPLEMENTED - :0:0:0:0 NOT IMPLEMENTED - :0:0:0:0 UNDEFINED VARIABLE - fuzz_crash_023.md:193:4:193:13 -UNUSED VARIABLE - fuzz_crash_023.md:166:2:166:6 -UNUSED VARIABLE - fuzz_crash_023.md:189:2:189:23 +UNUSED VARIABLE - fuzz_crash_023.md:164:2:164:18 UNUSED VARIABLE - fuzz_crash_023.md:165:2:165:14 +UNUSED VARIABLE - fuzz_crash_023.md:166:2:166:6 UNUSED VARIABLE - fuzz_crash_023.md:178:2:178:8 UNUSED VARIABLE - fuzz_crash_023.md:180:2:180:17 UNUSED VARIABLE - fuzz_crash_023.md:188:2:188:15 -UNUSED VARIABLE - fuzz_crash_023.md:164:2:164:18 +UNUSED VARIABLE - fuzz_crash_023.md:189:2:189:23 UNDECLARED TYPE - fuzz_crash_023.md:201:9:201:14 TYPE MISMATCH - fuzz_crash_023.md:67:11:67:14 INCOMPATIBLE MATCH PATTERNS - fuzz_crash_023.md:84:2:84:2 @@ -774,39 +774,39 @@ Is there an `import` or `exposing` missing up-top? **UNUSED VARIABLE** -Variable `list` is not used anywhere in your code. +Variable `tag_with_payload` 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. +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:166:2:166:6:** +**fuzz_crash_023.md:164:2:164:18:** ```roc - list = [ + tag_with_payload = Ok(number) ``` - ^^^^ + ^^^^^^^^^^^^^^^^ **UNUSED VARIABLE** -Variable `static_dispatch_style` is not used anywhere in your code. +Variable `interpolated` 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. +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:189:2:189:23:** +**fuzz_crash_023.md:165:2:165:14:** ```roc - static_dispatch_style = some_fn(arg1)?.static_dispatch_method()?.next_static_dispatch_method()?.record_field? + interpolated = "Hello, ${world}" ``` - ^^^^^^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^ **UNUSED VARIABLE** -Variable `interpolated` is not used anywhere in your code. +Variable `list` 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. +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:165:2:165:14:** +**fuzz_crash_023.md:166:2:166:6:** ```roc - interpolated = "Hello, ${world}" + list = [ ``` - ^^^^^^^^^^^^ + ^^^^ **UNUSED VARIABLE** @@ -846,15 +846,15 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `tag_with_payload` is not used anywhere in your code. +Variable `static_dispatch_style` 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. +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:164:2:164:18:** +**fuzz_crash_023.md:189:2:189:23:** ```roc - tag_with_payload = Ok(number) + static_dispatch_style = some_fn(arg1)?.static_dispatch_method()?.next_static_dispatch_method()?.record_field? ``` - ^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^ **UNDECLARED TYPE** diff --git a/src/snapshots/fuzz_crash/fuzz_crash_027.md b/src/snapshots/fuzz_crash/fuzz_crash_027.md index 594e4ee02e9..0c2704d795c 100644 --- a/src/snapshots/fuzz_crash/fuzz_crash_027.md +++ b/src/snapshots/fuzz_crash/fuzz_crash_027.md @@ -216,13 +216,13 @@ UNDEFINED VARIABLE - fuzz_crash_027.md:138:4:138:10 UNDEFINED VARIABLE - fuzz_crash_027.md:141:14:141:17 NOT IMPLEMENTED - :0:0:0:0 UNDEFINED VARIABLE - fuzz_crash_027.md:145:4:145:13 -UNUSED VARIABLE - fuzz_crash_027.md:131:2:131:8 -UNUSED VARIABLE - fuzz_crash_027.md:133:2:133:9 -UNUSED VARIABLE - fuzz_crash_027.md:142:2:142:7 -UNUSED VARIABLE - fuzz_crash_027.md:141:2:141:7 UNUSED VARIABLE - fuzz_crash_027.md:119:2:119:10 UNUSED VARIABLE - fuzz_crash_027.md:120:2:120:6 UNUSED VARIABLE - fuzz_crash_027.md:121:2:121:6 +UNUSED VARIABLE - fuzz_crash_027.md:131:2:131:8 +UNUSED VARIABLE - fuzz_crash_027.md:133:2:133:9 +UNUSED VARIABLE - fuzz_crash_027.md:141:2:141:7 +UNUSED VARIABLE - fuzz_crash_027.md:142:2:142:7 UNDECLARED TYPE - fuzz_crash_027.md:153:9:153:14 TYPE MISMATCH - fuzz_crash_027.md:47:11:47:14 INCOMPATIBLE MATCH PATTERNS - fuzz_crash_027.md:64:2:64:2 @@ -745,87 +745,87 @@ Is there an `import` or `exposing` missing up-top? **UNUSED VARIABLE** -Variable `record` is not used anywhere in your code. +Variable `tag_with` 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. +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:131:2:131:8:** +**fuzz_crash_027.md:119:2:119:10:** ```roc - record = { foo: 123, bar: "Hello", baz: tag, qux: Ok(world), punned } + tag_with = Ok(number) ``` - ^^^^^^ + ^^^^^^^^ **UNUSED VARIABLE** -Variable `m_tuple` is not used anywhere in your code. +Variable `ited` 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. +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:133:2:133:9:** +**fuzz_crash_027.md:120:2:120:6:** ```roc - m_tuple = ( + ited = "Hello, ${world}" ``` - ^^^^^^^ + ^^^^ **UNUSED VARIABLE** -Variable `stale` is not used anywhere in your code. +Variable `list` 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. +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:142:2:142:7:** +**fuzz_crash_027.md:121:2:121:6:** ```roc - stale = some_fn(arg1)?.statod()?.ned()?.recd? + list = [ ``` - ^^^^^ + ^^^^ **UNUSED VARIABLE** -Variable `bsult` is not used anywhere in your code. +Variable `record` 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. +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:141:2:141:7:** +**fuzz_crash_027.md:131:2:131:8:** ```roc - bsult = Err(foo) ?? 12 > 5 * 5 or 13 + 2 < 5 and 10 - 1 >= 16 or 12 <= 3 / 5 + record = { foo: 123, bar: "Hello", baz: tag, qux: Ok(world), punned } ``` - ^^^^^ + ^^^^^^ **UNUSED VARIABLE** -Variable `tag_with` is not used anywhere in your code. +Variable `m_tuple` 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. +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:119:2:119:10:** +**fuzz_crash_027.md:133:2:133:9:** ```roc - tag_with = Ok(number) + m_tuple = ( ``` - ^^^^^^^^ + ^^^^^^^ **UNUSED VARIABLE** -Variable `ited` is not used anywhere in your code. +Variable `bsult` 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. +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:120:2:120:6:** +**fuzz_crash_027.md:141:2:141:7:** ```roc - ited = "Hello, ${world}" + bsult = Err(foo) ?? 12 > 5 * 5 or 13 + 2 < 5 and 10 - 1 >= 16 or 12 <= 3 / 5 ``` - ^^^^ + ^^^^^ **UNUSED VARIABLE** -Variable `list` is not used anywhere in your code. +Variable `stale` 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. +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:121:2:121:6:** +**fuzz_crash_027.md:142:2:142:7:** ```roc - list = [ + stale = some_fn(arg1)?.statod()?.ned()?.recd? ``` - ^^^^ + ^^^^^ **UNDECLARED TYPE** diff --git a/src/snapshots/fuzz_crash/fuzz_crash_028.md b/src/snapshots/fuzz_crash/fuzz_crash_028.md index fd43c2c853f..90ab6455619 100644 Binary files a/src/snapshots/fuzz_crash/fuzz_crash_028.md and b/src/snapshots/fuzz_crash/fuzz_crash_028.md differ diff --git a/src/snapshots/match_expr/guards_2.md b/src/snapshots/match_expr/guards_2.md index 56ccc9615bf..95f389d5b23 100644 --- a/src/snapshots/match_expr/guards_2.md +++ b/src/snapshots/match_expr/guards_2.md @@ -38,8 +38,8 @@ PARSE ERROR - guards_2.md:3:62:3:62 UNEXPECTED TOKEN IN EXPRESSION - guards_2.md:3:62:3:63 UNDEFINED VARIABLE - guards_2.md:1:7:1:12 UNKNOWN OPERATOR - guards_2.md:2:50:2:51 -UNUSED VARIABLE - guards_2.md:1:1:1:1 UNUSED VARIABLE - guards_2.md:2:6:2:11 +UNUSED VARIABLE - guards_2.md:1:1:1:1 # PROBLEMS **PARSE ERROR** A parsing error occurred: `match_branch_missing_arrow` @@ -352,27 +352,27 @@ This looks like an operator, but it's not one I recognize! Check the spelling and make sure you're using a valid Roc operator like `+`, `-`, `==`. **UNUSED VARIABLE** -Variable `rest` is not used anywhere in your code. +Variable `first` 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. +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:1:1:1:1:** +**guards_2.md:2:6:2:11:** ```roc -match value { + [first, .. as rest] if List.len(rest) > 5 => "long list starting with ${Num.toStr first}" ``` - + ^^^^^ **UNUSED VARIABLE** -Variable `first` is not used anywhere in your code. +Variable `rest` 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. +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:6:2:11:** +**guards_2.md:1:1:1:1:** ```roc - [first, .. as rest] if List.len(rest) > 5 => "long list starting with ${Num.toStr first}" +match value { ``` - ^^^^^ + # TOKENS diff --git a/src/snapshots/match_expr/list_patterns.md b/src/snapshots/match_expr/list_patterns.md index 22decb74a31..3925764b82c 100644 --- a/src/snapshots/match_expr/list_patterns.md +++ b/src/snapshots/match_expr/list_patterns.md @@ -14,8 +14,8 @@ match numbers { BAD LIST REST PATTERN SYNTAX - list_patterns.md:3:13:3:19 UNDEFINED VARIABLE - list_patterns.md:1:7:1:14 UNDEFINED VARIABLE - list_patterns.md:2:11:2:14 -UNUSED VARIABLE - list_patterns.md:3:15:3:15 UNUSED VARIABLE - list_patterns.md:3:6:3:11 +UNUSED VARIABLE - list_patterns.md:3:15:3:15 # PROBLEMS **BAD LIST REST PATTERN SYNTAX** List rest patterns should use the `.. as name` syntax, not `..name`. @@ -52,27 +52,27 @@ Is there an `import` or `exposing` missing up-top? **UNUSED VARIABLE** -Variable `rest` is not used anywhere in your code. +Variable `first` 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. +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:15:3:15:** +**list_patterns.md:3:6:3:11:** ```roc [first, ..rest] => 0 # invalid rest pattern should error ``` - + ^^^^^ **UNUSED VARIABLE** -Variable `first` is not used anywhere in your code. +Variable `rest` 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. +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:6:3:11:** +**list_patterns.md:3:15:3:15:** ```roc [first, ..rest] => 0 # invalid rest pattern should error ``` - ^^^^^ + # TOKENS diff --git a/src/snapshots/match_expr/list_rest_invalid.md b/src/snapshots/match_expr/list_rest_invalid.md index ea4ce3b4259..6ad2dba25ae 100644 --- a/src/snapshots/match_expr/list_rest_invalid.md +++ b/src/snapshots/match_expr/list_rest_invalid.md @@ -16,13 +16,13 @@ BAD LIST REST PATTERN SYNTAX - list_rest_invalid.md:2:13:2:19 BAD LIST REST PATTERN SYNTAX - list_rest_invalid.md:3:6:3:12 BAD LIST REST PATTERN SYNTAX - list_rest_invalid.md:4:9:4:15 UNDEFINED VARIABLE - list_rest_invalid.md:1:7:1:12 -UNUSED VARIABLE - list_rest_invalid.md:2:15:2:15 UNUSED VARIABLE - list_rest_invalid.md:2:6:2:11 +UNUSED VARIABLE - list_rest_invalid.md:2:15:2:15 UNUSED VARIABLE - list_rest_invalid.md:3:8:3:8 UNUSED VARIABLE - list_rest_invalid.md:3:14:3:18 -UNUSED VARIABLE - list_rest_invalid.md:4:17:4:18 UNUSED VARIABLE - list_rest_invalid.md:4:6:4:7 UNUSED VARIABLE - list_rest_invalid.md:4:11:4:11 +UNUSED VARIABLE - list_rest_invalid.md:4:17:4:18 # PROBLEMS **BAD LIST REST PATTERN SYNTAX** List rest patterns should use the `.. as name` syntax, not `..name`. @@ -72,27 +72,27 @@ match items { **UNUSED VARIABLE** -Variable `rest` is not used anywhere in your code. +Variable `first` 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. +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:15:2:15:** +**list_rest_invalid.md:2:6:2:11:** ```roc [first, ..rest] => 0 # invalid rest pattern should error ``` - + ^^^^^ **UNUSED VARIABLE** -Variable `first` is not used anywhere in your code. +Variable `rest` 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. +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:6:2:11:** +**list_rest_invalid.md:2:15:2:15:** ```roc [first, ..rest] => 0 # invalid rest pattern should error ``` - ^^^^^ + **UNUSED VARIABLE** @@ -119,18 +119,6 @@ The unused variable is declared here: ^^^^ -**UNUSED VARIABLE** -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 -``` - ^ - - **UNUSED VARIABLE** Variable `x` is not used anywhere in your code. @@ -155,6 +143,18 @@ The unused variable is declared here: +**UNUSED VARIABLE** +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 +``` + ^ + + # TOKENS ~~~zig KwMatch(1:1-1:6),LowerIdent(1:7-1:12),OpenCurly(1:13-1:14), diff --git a/src/snapshots/rigid_var_no_instantiation_error.md b/src/snapshots/rigid_var_no_instantiation_error.md index 4b6997d298e..dad5ece8194 100644 --- a/src/snapshots/rigid_var_no_instantiation_error.md +++ b/src/snapshots/rigid_var_no_instantiation_error.md @@ -33,8 +33,8 @@ main! = |_| { # EXPECTED UNDEFINED VARIABLE - rigid_var_no_instantiation_error.md:17:21:17:30 UNUSED VARIABLE - rigid_var_no_instantiation_error.md:13:5:13:12 -UNUSED VARIABLE - rigid_var_no_instantiation_error.md:21:5:21:12 UNUSED VARIABLE - rigid_var_no_instantiation_error.md:17:5:17:12 +UNUSED VARIABLE - rigid_var_no_instantiation_error.md:21:5:21:12 # PROBLEMS **UNDEFINED VARIABLE** Nothing is named `true` in this scope. @@ -60,25 +60,25 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `result3` is not used anywhere in your code. +Variable `result2` 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. +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:21:5:21:12:** +**rigid_var_no_instantiation_error.md:17:5:17:12:** ```roc - result3 = swap(("foo", "bar")) + result2 = swap((Bool.true, [1, 2, 3])) ``` ^^^^^^^ **UNUSED VARIABLE** -Variable `result2` is not used anywhere in your code. +Variable `result3` 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. +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:17:5:17:12:** +**rigid_var_no_instantiation_error.md:21:5:21:12:** ```roc - result2 = swap((Bool.true, [1, 2, 3])) + result3 = swap(("foo", "bar")) ``` ^^^^^^^ diff --git a/src/snapshots/syntax_grab_bag.md b/src/snapshots/syntax_grab_bag.md index ad1a3dd739b..bcd4ec22731 100644 --- a/src/snapshots/syntax_grab_bag.md +++ b/src/snapshots/syntax_grab_bag.md @@ -259,13 +259,13 @@ UNDEFINED VARIABLE - syntax_grab_bag.md:188:22:188:25 NOT IMPLEMENTED - :0:0:0:0 NOT IMPLEMENTED - :0:0:0:0 UNDEFINED VARIABLE - syntax_grab_bag.md:193:4:193:13 -UNUSED VARIABLE - syntax_grab_bag.md:166:2:166:6 -UNUSED VARIABLE - syntax_grab_bag.md:180:2:180:17 -UNUSED VARIABLE - syntax_grab_bag.md:189:2:189:23 +UNUSED VARIABLE - syntax_grab_bag.md:164:2:164:18 UNUSED VARIABLE - syntax_grab_bag.md:165:2:165:14 +UNUSED VARIABLE - syntax_grab_bag.md:166:2:166:6 UNUSED VARIABLE - syntax_grab_bag.md:178:2:178:8 +UNUSED VARIABLE - syntax_grab_bag.md:180:2:180:17 UNUSED VARIABLE - syntax_grab_bag.md:188:2:188:15 -UNUSED VARIABLE - syntax_grab_bag.md:164:2:164:18 +UNUSED VARIABLE - syntax_grab_bag.md:189:2:189:23 UNDECLARED TYPE - syntax_grab_bag.md:201:9:201:14 TYPE MISMATCH - syntax_grab_bag.md:67:11:67:14 INCOMPATIBLE MATCH PATTERNS - syntax_grab_bag.md:84:2:84:2 @@ -710,63 +710,63 @@ Is there an `import` or `exposing` missing up-top? **UNUSED VARIABLE** -Variable `list` is not used anywhere in your code. +Variable `tag_with_payload` 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. +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:166:2:166:6:** +**syntax_grab_bag.md:164:2:164:18:** ```roc - list = [ + tag_with_payload = Ok(number) ``` - ^^^^ + ^^^^^^^^^^^^^^^^ **UNUSED VARIABLE** -Variable `multiline_tuple` is not used anywhere in your code. +Variable `interpolated` 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. +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:180:2:180:17:** +**syntax_grab_bag.md:165:2:165:14:** ```roc - multiline_tuple = ( + interpolated = "Hello, ${world}" ``` - ^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^ **UNUSED VARIABLE** -Variable `static_dispatch_style` is not used anywhere in your code. +Variable `list` 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. +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:189:2:189:23:** +**syntax_grab_bag.md:166:2:166:6:** ```roc - static_dispatch_style = some_fn(arg1)?.static_dispatch_method()?.next_static_dispatch_method()?.record_field? + list = [ ``` - ^^^^^^^^^^^^^^^^^^^^^ + ^^^^ **UNUSED VARIABLE** -Variable `interpolated` is not used anywhere in your code. +Variable `record` 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. +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:165:2:165:14:** +**syntax_grab_bag.md:178:2:178:8:** ```roc - interpolated = "Hello, ${world}" + record = { foo: 123, bar: "Hello", baz: tag, qux: Ok(world), punned } ``` - ^^^^^^^^^^^^ + ^^^^^^ **UNUSED VARIABLE** -Variable `record` is not used anywhere in your code. +Variable `multiline_tuple` 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. +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:178:2:178:8:** +**syntax_grab_bag.md:180:2:180:17:** ```roc - record = { foo: 123, bar: "Hello", baz: tag, qux: Ok(world), punned } + multiline_tuple = ( ``` - ^^^^^^ + ^^^^^^^^^^^^^^^ **UNUSED VARIABLE** @@ -782,15 +782,15 @@ The unused variable is declared here: **UNUSED VARIABLE** -Variable `tag_with_payload` is not used anywhere in your code. +Variable `static_dispatch_style` 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. +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:164:2:164:18:** +**syntax_grab_bag.md:189:2:189:23:** ```roc - tag_with_payload = Ok(number) + static_dispatch_style = some_fn(arg1)?.static_dispatch_method()?.next_static_dispatch_method()?.record_field? ``` - ^^^^^^^^^^^^^^^^ + ^^^^^^^^^^^^^^^^^^^^^ **UNDECLARED TYPE**