From 207bcd48613a9dc9c799cf34762ffff01f86c232 Mon Sep 17 00:00:00 2001 From: Marco Iannaccone Date: Fri, 12 Jun 2026 23:03:41 +0200 Subject: [PATCH] Use typed integer literals so Std builds under strict overload resolution --- Src/Assert.rux | 2 +- Src/Char16.rux | 6 +++--- Src/Char32.rux | 8 ++++---- Src/Char8.rux | 2 +- Src/Fatal.rux | 2 +- Src/Memory.rux | 16 ++++++++-------- Src/Print.rux | 2 +- Src/String.rux | 3 +-- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Src/Assert.rux b/Src/Assert.rux index 00eea2e..f4989ea 100644 --- a/Src/Assert.rux +++ b/Src/Assert.rux @@ -15,7 +15,7 @@ module Std { String::From(file) + ":" + Format("{}", line) + ":" + Format("{}", column) + "\n in function " + String::From(function) + "\n"; Print(output); - Exit(2); + Exit(2u32); } } } diff --git a/Src/Char16.rux b/Src/Char16.rux index efc0667..13a10de 100644 --- a/Src/Char16.rux +++ b/Src/Char16.rux @@ -10,17 +10,17 @@ module Std { let cp = value as uint; if cp < 0x80 { buf[0] = cp as char8; - return String::From(buf.data, 1); + return String::From(buf.data, 1u); } if cp < 0x800 { buf[0] = (0xC0 | (cp >> 6)) as char8; buf[1] = (0x80 | (cp & 0x3F)) as char8; - return String::From(buf.data, 2); + return String::From(buf.data, 2u); } buf[0] = (0xE0 | (cp >> 12)) as char8; buf[1] = (0x80 | ((cp >> 6) & 0x3F)) as char8; buf[2] = (0x80 | (cp & 0x3F)) as char8; - return String::From(buf.data, 3); + return String::From(buf.data, 3u); } extend char16 : Display { diff --git a/Src/Char32.rux b/Src/Char32.rux index 0676c97..a3c6758 100644 --- a/Src/Char32.rux +++ b/Src/Char32.rux @@ -10,24 +10,24 @@ module Std { let cp = value as uint; if cp < 0x80 { buf[0] = cp as char8; - return String::From(buf.data, 1); + return String::From(buf.data, 1u); } if cp < 0x800 { buf[0] = (0xC0 | (cp >> 6)) as char8; buf[1] = (0x80 | (cp & 0x3F)) as char8; - return String::From(buf.data, 2); + return String::From(buf.data, 2u); } if cp < 0x10000 { buf[0] = (0xE0 | (cp >> 12)) as char8; buf[1] = (0x80 | ((cp >> 6) & 0x3F)) as char8; buf[2] = (0x80 | (cp & 0x3F)) as char8; - return String::From(buf.data, 3); + return String::From(buf.data, 3u); } buf[0] = (0xF0 | (cp >> 18)) as char8; buf[1] = (0x80 | ((cp >> 12) & 0x3F)) as char8; buf[2] = (0x80 | ((cp >> 6) & 0x3F)) as char8; buf[3] = (0x80 | (cp & 0x3F)) as char8; - return String::From(buf.data, 4); + return String::From(buf.data, 4u); } extend char32 : Display { diff --git a/Src/Char8.rux b/Src/Char8.rux index 07bab25..a3c843d 100644 --- a/Src/Char8.rux +++ b/Src/Char8.rux @@ -8,7 +8,7 @@ module Std { func ToString(value: char8) -> String { var buf: char8[1]; buf[0] = value; - return String::From(buf.data, 1); + return String::From(buf.data, 1u); } extend char8 : Display { diff --git a/Src/Fatal.rux b/Src/Fatal.rux index 45a55fd..dccfb5c 100644 --- a/Src/Fatal.rux +++ b/Src/Fatal.rux @@ -15,6 +15,6 @@ module Std { String::From(file) + ":" + Format("{}", line) + ":" + Format("{}", column) + "\n in function " + String::From(function) + "\n"; Print(output); - Exit(1); + Exit(1u32); } } \ No newline at end of file diff --git a/Src/Memory.rux b/Src/Memory.rux index 849586c..234421c 100644 --- a/Src/Memory.rux +++ b/Src/Memory.rux @@ -100,7 +100,7 @@ module Std::Memory { @[Target("MacOS")] func Alloc(size: uint) -> *opaque { let total = size + HeaderSize; - let mapping = HeapAlloc(GetProcessHeap(), 0, total); + let mapping = HeapAlloc(GetProcessHeap(), 0u32, total); if mapping == null || (mapping as int64) == -1i64 { return null; } @@ -112,7 +112,7 @@ module Std::Memory { @[Target("Windows")] func Alloc(size: uint) -> *opaque { - return HeapAlloc(GetProcessHeap(), 0, size); + return HeapAlloc(GetProcessHeap(), 0u32, size); } @[Target("BSD")] @@ -209,7 +209,7 @@ module Std::Memory { @[Target("Windows")] func Realloc(ptr: *opaque, size: uint) -> *opaque { - return HeapReAlloc(GetProcessHeap(), 0, ptr, size); + return HeapReAlloc(GetProcessHeap(), 0u32, ptr, size); } @[Target("BSD")] @@ -254,7 +254,7 @@ module Std::Memory { @[Target("Windows")] func Free(ptr: *opaque) { - HeapFree(GetProcessHeap(), 0, ptr); + HeapFree(GetProcessHeap(), 0u32, ptr); } @[Target("BSD")] @@ -304,22 +304,22 @@ module Std::Memory { @[Target("BSD")] func Zero(ptr: *opaque, size: uint) { - Set(ptr, size, 0); + Set(ptr, size, 0i32); } @[Target("Illumos")] func Zero(ptr: *opaque, size: uint) { - Set(ptr, size, 0); + Set(ptr, size, 0i32); } @[Target("Linux")] func Zero(ptr: *opaque, size: uint) { - Set(ptr, size, 0); + Set(ptr, size, 0i32); } @[Target("MacOS")] func Zero(ptr: *opaque, size: uint) { - Set(ptr, size, 0); + Set(ptr, size, 0i32); } @[Target("Windows")] diff --git a/Src/Print.rux b/Src/Print.rux index 3c814e2..6831b0f 100644 --- a/Src/Print.rux +++ b/Src/Print.rux @@ -151,7 +151,7 @@ module Std::Io { Fatal("string is too long to print"); } var wideBuf: char16[MaxLength]; - let wideLen = MultiByteToWideChar(CodePage::Utf8 as uint32, 0, string, length as int32, wideBuf.data, wideBuf.length as int32); + let wideLen = MultiByteToWideChar(CodePage::Utf8 as uint32, 0u32, string, length as int32, wideBuf.data, wideBuf.length as int32); Print(wideBuf.data, wideLen as uint); } diff --git a/Src/String.rux b/Src/String.rux index b99d204..1aaa45b 100644 --- a/Src/String.rux +++ b/Src/String.rux @@ -25,7 +25,6 @@ module Std { } extend String { - func New() -> String { return String { data: null, length: 0 }; } @@ -162,7 +161,7 @@ module Std { if first == self.length { return String { - data: Alloc(0) as *char8, + data: Alloc(0u) as *char8, length: 0 }; }