Skip to content

Commit 7bd7460

Browse files
committed
fix infinite loop in parser
the last change introduced a regression where the parser would never return null under certain circumstances
1 parent 458ed47 commit 7bd7460

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Parser.zig

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ pub const Node = struct {
3939
};
4040

4141
pub fn next(p: *Parser, code: []const u8) ?Node {
42+
if (p.it.idx == code.len) {
43+
const in_terminal_state = (p.state == .after_call or
44+
p.state == .extend_path);
45+
if (in_terminal_state) return null;
46+
return p.syntaxError(.{
47+
.start = p.it.idx,
48+
.end = p.it.idx,
49+
});
50+
}
4251
var path: Node = .{
4352
.tag = .path,
4453
.loc = undefined,

0 commit comments

Comments
 (0)