bugfixes and improvements to reader.lines
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 13 Feb 2023 03:23:12 +0000 (21:23 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 13 Feb 2023 03:23:12 +0000 (21:23 -0600)
compiler/src/checker.c
core/builtin.onyx
core/encoding/csv.onyx
core/io/reader.onyx

index a927773494f562da03f60383cbde9589e1f31f06..2fa0d62fa4ea9bb0514f61e34bc20b67665031a5 100644 (file)
@@ -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;
         }
index e79260330c02228ef133c90321044e6a0a9867b3..55540402e0504c22ac3787dfc8b125d0dc6e3ebd 100644 (file)
@@ -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,
index 9fdf3d167f18ba8d94050f7abcea198ed18952f4..3f03ae0e3835b28c12201cf46356b7a479d5d928 100644 (file)
@@ -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 ",")
index d39f3a3a316504547e0dd131783ad441fb1374b4..bb0a5bacda61662d5a3547ace9ee2f0428f6b2c4 100644 (file)
@@ -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;