diff --git a/lib/std/io/formatter.c3 b/lib/std/io/formatter.c3 index eb7b9dd07..1117f7b66 100644 --- a/lib/std/io/formatter.c3 +++ b/lib/std/io/formatter.c3 @@ -136,7 +136,7 @@ fn usz? Formatter.print_with_function(&self, Printable arg) fn usz? Formatter.out_unknown(&self, String category, any arg) @private { - return self.out_substr("[") + self.out_substr(category) + self.out_substr(" type:") + self.ntoa((iptr)arg.type, false, 16) + self.out_substr(", addr:") + self.ntoa((iptr)arg.ptr, false, 16) + self.out_substr("]"); + return self.out_substr("<") + self.out_substr(category) + self.out_substr(" type:") + self.ntoa((iptr)arg.type, false, 16) + self.out_substr(", addr:") + self.ntoa((iptr)arg.ptr, false, 16) + self.out_substr(">"); } fn usz? Formatter.out_str(&self, any arg) @private { @@ -196,7 +196,15 @@ fn usz? Formatter.out_str(&self, any arg) @private case BITSTRUCT: return self.out_unknown("bitstruct", arg); case FUNC: - return self.out_unknown("function", arg); + PrintFlags flags = self.flags; + uint width = self.width; + defer + { + self.flags = flags; + self.width = width; + } + self.width = 0; + return self.out_substr("0x")! + self.ntoa_any(arg, 16); case DISTINCT: if (arg.type == String.typeid) { diff --git a/lib/std/io/formatter_private.c3 b/lib/std/io/formatter_private.c3 index e3251dfe2..ab019d74a 100644 --- a/lib/std/io/formatter_private.c3 +++ b/lib/std/io/formatter_private.c3 @@ -39,10 +39,11 @@ fn uint128? int_from_any(any arg, bool *is_neg) @private { switch (arg.type.kindof) { - case TypeKind.POINTER: + case FUNC: + case POINTER: *is_neg = false; return (uint128)(uptr)*(void**)arg.ptr; - case TypeKind.DISTINCT: + case DISTINCT: return int_from_any(arg.as_inner(), is_neg); default: break; diff --git a/releasenotes.md b/releasenotes.md index b2435d820..480147bc5 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -31,6 +31,7 @@ - `@ensure` was not included when the function doesn't return a value #2098. - Added missing `@clone_aligned` and add checks to `@tclone` - Comparing a distinct type with an enum with an inline distinct type failed unexpectedly. +- The `%s` would not properly print function pointers. ### Stdlib changes - Hash functions for integer vectors and arrays.