Skip to content

Captures error #38

@gabihodoroaga

Description

@gabihodoroaga

Hi,

I'm trying to use captures and I get the following error:

Users/user/.cache/zig/p/regex-0.1.2-axC356XdAQCrReHJQmJLbCDBoYVvzj8y-wE1PXUjT4V6/src/regex.zig:129:51: 0x100c173e3 in boundsAt (zig-regex-test)
                const upper = self.slots[base + 1].?;
                                                  ^
/Users/user/.cache/zig/p/regex-0.1.2-axC356XdAQCrReHJQmJLbCDBoYVvzj8y-wE1PXUjT4V6/src/regex.zig:116:26: 0x100c16ee7 in sliceAt (zig-regex-test)
        if (self.boundsAt(n)) |span| {
                         ^
/Users/user/Projects/zig-regex-test/src/main.zig:49:26: 0x100c17a53 in test.url test 2 (zig-regex-test)
            if (c.sliceAt(i)) |data| {
                         ^
/opt/homebrew/Cellar/zig/0.14.0_2/lib/zig/compiler/test_runner.zig:126:29: 0x100c3110f in mainServer (zig-regex-test)
                test_fn.func() catch |err| switch (err) {
                            ^
/opt/homebrew/Cellar/zig/0.14.0_2/lib/zig/compiler/test_runner.zig:60:26: 0x100c2cca3 in main (zig-regex-test)
        return mainServer() catch @panic("internal test runner failure");
                         ^
/opt/homebrew/Cellar/zig/0.14.0_2/lib/zig/std/start.zig:647:22: 0x100c2c71f in main (zig-regex-test)
            root.main();

for this test

test "url test 2" {
    var gpa = std.heap.DebugAllocator(.{}).init;
    const allocator = gpa.allocator();

    var re = try Regex.compile(allocator, "^(([a-z]+)*(:[a-z]+)*@)?(([a-z]+))(:[\\d]+)*$");
    const captures = try re.captures("testuser@localhost:2222");

    if (captures) |c| {
        for (0..7) |i| {
            if (c.sliceAt(i)) |data| {
                print("slice at {} {s}\n", .{ i, data });
            }
        }
    }
}

Is failing for the optional capturing groups.

For this input testuser:testpass@localhost:2222 the test does not fail.

Thanks,
gabihodoroaga

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions