From 0a08303870201cff5665d35a71276bd3d7134bda Mon Sep 17 00:00:00 2001 From: "A. R. Shajii" Date: Thu, 5 Jan 2023 11:40:49 -0500 Subject: [PATCH] Update format error checking Simplifies LLVM IR output when not using format strings --- stdlib/internal/format.codon | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/internal/format.codon b/stdlib/internal/format.codon index c7fb1769..145ac1ee 100644 --- a/stdlib/internal/format.codon +++ b/stdlib/internal/format.codon @@ -8,7 +8,7 @@ class int: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_int(self, format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret @@ -17,7 +17,7 @@ class Int: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_int(self.__int__(), format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret @@ -26,7 +26,7 @@ class UInt: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_uint(self.__int__(), format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret @@ -35,7 +35,7 @@ class float: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_float(self, format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret if ret != "-nan" else "nan" @@ -44,7 +44,7 @@ class str: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_str(self, format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret @@ -53,6 +53,6 @@ class Ptr: def __format__(self, format_spec: str) -> str: err = False ret = _C.seq_str_ptr(self.as_byte(), format_spec, __ptr__(err)) - if err: + if format_spec and err: _format_error(ret) return ret