Last active
June 2, 2022 20:13
-
-
Save MichaelBelousov/03dadd8a5e3e030e2e312f95b0a92344 to your computer and use it in GitHub Desktop.
zig compile error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! parser for nodelang written in zig | |
pub const Tok = enum { | |
colon, | |
other, // need at least two here to trigger it | |
}; | |
const Token = struct { | |
tok: Tok, | |
str: []const u8, | |
pub fn new(tok: Tok, str: []const u8) Token { | |
return Token{.tok=tok, .str=str}; | |
} | |
}; | |
fn parseMany(comptime tokOrNodeTypes: [2]Tok) !?u32 { | |
// inline for seems to be necessary, I tried manually inlining | |
inline for (tokOrNodeTypes) |tokType| { | |
// manually inlining Token.new prevents the compiler segfault from appearing | |
const tok = try @as(anyerror!Token, Token.new(Tok.colon, ":")); | |
// being in the else clause seems to be necessary | |
if (tok.tok != tokType) {} else { | |
while (true) { | |
// returning instead of breaking seems to be necessary | |
return null; | |
} | |
} | |
} | |
return 0; | |
} | |
pub fn main() !void { | |
_ = try parseMany(.{Tok.colon, Tok.colon}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fails to compile on: compiler:
0.10.0-dev.290+3901b6fb0