motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit 548fd6e87bb8edf20f5ea69b866f8b13f9ad2787 (tree)
parent 3811602ad72ed1823e06d2e6d2cb646bc81ca5f9
Author: Rocknest <35231115+Rocknest@users.noreply.github.com>
Date:   Sun, 11 Oct 2020 17:06:46 +0300

force comptime on comptimePrint

Diffstat:
Mlib/std/fmt.zig | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig @@ -1182,10 +1182,12 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti } pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args):0]u8 { - comptime var buf: [count(fmt, args):0]u8 = undefined; - _ = bufPrint(&buf, fmt, args) catch unreachable; - buf[buf.len] = 0; - return &buf; + comptime { + var buf: [count(fmt, args):0]u8 = undefined; + _ = bufPrint(&buf, fmt, args) catch unreachable; + buf[buf.len] = 0; + return &buf; + } } test "comptimePrint" {