From e3e8d84e0473b525db26fff130614c3098481c6c Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 13 Mar 2024 14:17:39 +0100 Subject: [PATCH] fix: Don't warn about unused import in the REPL --- src/Parser.zig | 22 ++++++++++++---------- tests/053-range.buzz | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Parser.zig b/src/Parser.zig index 09fe6482..528fa988 100644 --- a/src/Parser.zig +++ b/src/Parser.zig @@ -904,17 +904,19 @@ pub fn parse(self: *Self, source: []const u8, file_name: []const u8) !?Ast { } // Check there's no unreferenced imports - var it = self.script_imports.iterator(); - while (it.next()) |kv| { - if (!kv.value_ptr.*.referenced) { - const location = self.ast.tokens.get(kv.value_ptr.*.location); + if (self.flavor != .Repl) { + var it = self.script_imports.iterator(); + while (it.next()) |kv| { + if (!kv.value_ptr.*.referenced) { + const location = self.ast.tokens.get(kv.value_ptr.*.location); - self.reporter.warnFmt( - .unused_import, - location, - "Unused import", - .{}, - ); + self.reporter.warnFmt( + .unused_import, + location, + "Unused import", + .{}, + ); + } } } diff --git a/tests/053-range.buzz b/tests/053-range.buzz index a83ed0b8..75e0f05f 100644 --- a/tests/053-range.buzz +++ b/tests/053-range.buzz @@ -4,6 +4,7 @@ test "Range" { int limit = 10; range rg = 0..limit; + std.assert(rg == 0..10, message: "Could compare ranges"); std.assert(rg.low == 0, message: "Could get low limit of range"); std.assert(rg.high == 10, message: "Could get high limit of range");