From a58d782704f18dc9b705db36ccde8b3341c3964d Mon Sep 17 00:00:00 2001 From: Ellipse12 <53803593+ellipse12@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:07:34 -0700 Subject: [PATCH] added check for to_string in is_struct_with_default_print The function wasn't checking if the struct had the method `to_string` which made it segfault when trying to override the default to_string on a struct --- lib/std/io/formatter.c3 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/std/io/formatter.c3 b/lib/std/io/formatter.c3 index f66882057..fe4f1c76d 100644 --- a/lib/std/io/formatter.c3 +++ b/lib/std/io/formatter.c3 @@ -28,7 +28,8 @@ macro bool is_struct_with_default_print($Type) { return $Type.kindof == STRUCT &&& !$defined($Type.to_format) - &&& !$defined($Type.to_new_string); + &&& !$defined($Type.to_new_string) + &&& !$defined($Type.to_string); } <* @@ -529,4 +530,4 @@ fn usz! Formatter.print(&self, String str) } foreach (c : str) self.out(c)!; return self.idx; -} \ No newline at end of file +}