Skip to content

Commit

Permalink
fix: Don't warn about unused import in the REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed Mar 13, 2024
1 parent 3497e6c commit e3e8d84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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",
.{},
);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/053-range.buzz
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit e3e8d84

Please sign in to comment.