aboutsummaryrefslogtreecommitdiff
path: root/lib/std/unicode.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-03-05 12:39:32 +0000
committerAndrew Kelley <andrew@ziglang.org>2023-04-12 12:06:19 -0400
commitccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0 (patch)
tree3f7899bf6231500782af185ffe701ee66793e226 /lib/std/unicode.zig
parent602029bb2fb78048e46136784e717b57b8de8f2c (diff)
downloadzig-ccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0.tar.gz
zig-ccf670c2b04ebeb9db43eb9f5c47c6cf03e4b1d0.zip
Zir: implement explicit block_comptime instruction
Resolves: #7056
Diffstat (limited to 'lib/std/unicode.zig')
-rw-r--r--lib/std/unicode.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig
index 7ac641e948..378b216ef3 100644
--- a/lib/std/unicode.zig
+++ b/lib/std/unicode.zig
@@ -774,13 +774,13 @@ test "utf8ToUtf16LeWithNull" {
/// Converts a UTF-8 string literal into a UTF-16LE string literal.
pub fn utf8ToUtf16LeStringLiteral(comptime utf8: []const u8) *const [calcUtf16LeLen(utf8) catch unreachable:0]u16 {
- comptime {
+ return comptime blk: {
const len: usize = calcUtf16LeLen(utf8) catch |err| @compileError(err);
var utf16le: [len:0]u16 = [_:0]u16{0} ** len;
const utf16le_len = utf8ToUtf16Le(&utf16le, utf8[0..]) catch |err| @compileError(err);
assert(len == utf16le_len);
- return &utf16le;
- }
+ break :blk &utf16le;
+ };
}
const CalcUtf16LeLenError = Utf8DecodeError || error{Utf8InvalidStartByte};