From 87e0019e6acb56cb344aa5c7639bea8dd7ad287d Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sun, 12 Feb 2023 21:23:12 -0600 Subject: [PATCH] bugfixes and improvements to reader.lines --- compiler/src/checker.c | 4 ++++ core/builtin.onyx | 2 +- core/encoding/csv.onyx | 4 +--- core/io/reader.onyx | 7 ++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/compiler/src/checker.c b/compiler/src/checker.c index a9277734..2fa0d62f 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -591,6 +591,10 @@ static CheckStatus check_resolve_callee(AstCall* call, AstTyped** effective_call &call->args); if (new_callee == NULL) { + if (context.cycle_almost_detected < 2) { + YIELD(call->token->pos, "Waiting to know all options for overloaded function"); + } + report_unable_to_match_overload(call, ((AstOverloadedFunction *) callee)->overloads); return Check_Error; } diff --git a/core/builtin.onyx b/core/builtin.onyx index e7926033..55540402 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -100,7 +100,7 @@ OnyxContext :: struct { // Defines what happens when `log()` is called. Defaults to a // logger that filters log messages by their severity. - logger : Logger = .{ Default_Logger.log, ^default_logger }; + logger : Logger = .{ default_logger_proc, ^default_logger }; // Defines what happens when an `assert()` check fails. Defaults // to printing the error and running an unreachable instruction, diff --git a/core/encoding/csv.onyx b/core/encoding/csv.onyx index 9fdf3d16..3f03ae0e 100644 --- a/core/encoding/csv.onyx +++ b/core/encoding/csv.onyx @@ -102,9 +102,7 @@ CSV_Column :: struct { } } - for line: reader->lines() { - defer string.free(line); - + for line: reader->lines(allocator = context.temp_allocator) { out: csv.Output_Type; for entry: string.split_iter(line, #char ",") diff --git a/core/io/reader.onyx b/core/io/reader.onyx index d39f3a3a..bb0a5bac 100644 --- a/core/io/reader.onyx +++ b/core/io/reader.onyx @@ -554,12 +554,13 @@ skip_bytes :: (use reader: ^Reader, bytes: u32) -> (skipped: i32, err: Error) { return 0, .None; } -lines :: (r: ^Reader, inplace := false) => +lines :: (r: ^Reader, inplace := false, allocator := context.allocator) => iter.generator(^.{ r = r, - inplace = inplace + inplace = inplace, + allocator = allocator, }, (ctx: $C) -> (str, bool) { - line := ctx.r->read_line(consume_newline=true, inplace=ctx.inplace); + line := ctx.r->read_line(consume_newline=true, inplace=ctx.inplace, allocator=ctx.allocator); if line.count > 0 do return line, true; else do return "", false; -- 2.25.1