aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-13 08:44:16 +0000
committer_ov4 <ov4@ov4.org>2026-10-13 08:44:16 +0000
commit58e2cfe505ba9942524f06bb1b1419e6c579efad (patch)
tree9a9ec110ce429a4fe2014987423c30be505274ae
parentc6dbd14ec8ff94df47d3c2137cc5234203ec5e0c (diff)
fix: preserve 64-bit integers in NUM_TO_STR
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
-rw-r--r--AGENTS/PITFALLS.md4
-rw-r--r--lib/CodeGen/StringConversionHandler.cc2
2 files changed, 3 insertions, 3 deletions
diff --git a/AGENTS/PITFALLS.md b/AGENTS/PITFALLS.md
index 6d1b196..fd53883 100644
--- a/AGENTS/PITFALLS.md
+++ b/AGENTS/PITFALLS.md
@@ -29,8 +29,8 @@ test programs.
must be a variable"; annotate `BYVAL` explicitly.
- **`/` always yields REAL** (double FDiv), even for two INTEGERs; integer division is
DIV/MOD only. CHR returns a STRING (2-byte heap buffer), not CHAR. STR_TO_NUM always
- returns REAL. NUM_TO_STR formats i64 with sprintf `"%d"` — corrupts values over 32
- bits.
+ returns REAL. NUM_TO_STR formats INTEGER with sprintf `"%lld"` (the full signed
+ i64 range) and REAL with `"%f"`.
- **`getExprTypeInfo` returns nullptr** for expressions it can't classify (null-check it
at any new call site) and internally defaults to INTEGER for arithmetic binaries and
unknown-function calls; OUTPUT reports an error for a nullptr result.
diff --git a/lib/CodeGen/StringConversionHandler.cc b/lib/CodeGen/StringConversionHandler.cc
index 62b99d7..af7f385 100644
--- a/lib/CodeGen/StringConversionHandler.cc
+++ b/lib/CodeGen/StringConversionHandler.cc
@@ -30,7 +30,7 @@ Value *StringConversionHandler::emitNumToStr(Value *Num, bool IsReal) {
if (IsReal) {
FormatStr = Builder.CreateGlobalStringPtr("%f");
} else {
- FormatStr = Builder.CreateGlobalStringPtr("%d");
+ FormatStr = Builder.CreateGlobalStringPtr("%lld");
}
Builder.CreateCall(SprintfFunc, {Buffer, FormatStr, Num});