Skip to content

Commit 9349d08

Browse files
linusgikskuh
authored andcommitted
Don't capture comptime slice in struct type
This now fails with a compile error: src/tokenizer.zig:142:16: error: type capture contains reference to comptime var return struct { ^~~~~~ src/tokenizer.zig:366:46: note: called from here comptime matchers.takeAnyOfIgnoreCase("abc"), ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
1 parent c6ebc5b commit 9349d08

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/tokenizer.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,15 @@ pub const matchers = struct {
136136
pub fn takeAnyOfIgnoreCase(comptime chars: []const u8) Matcher {
137137
const lower_chars = comptime blk: {
138138
var buffer: [chars.len]u8 = undefined;
139-
break :blk std.ascii.lowerString(&buffer, chars);
139+
_ = std.ascii.lowerString(&buffer, chars);
140+
break :blk buffer;
140141
};
141142

142143
return struct {
143144
fn match(str: []const u8) ?usize {
144145
for (str, 0..) |c, i| {
145146
const lc = std.ascii.toLower(c);
146-
if (std.mem.indexOfScalar(u8, lower_chars, lc) == null) {
147+
if (std.mem.indexOfScalar(u8, &lower_chars, lc) == null) {
147148
return i;
148149
}
149150
}

0 commit comments

Comments
 (0)