Skip to content

panic: reached unreachable code #8936

@JRI98

Description

@JRI98
./zig-out/bin/roc test file.roc
nth : List(a), U64 -> Try(a, [OutOfBounds])
nth = |l, i| {
	match (l, i) {
		([], _) => Err(OutOfBounds)
		([e, ..], 0) => Ok(e)
		([_, .. as rest], _) => nth(rest, (i - 1))
	}
}

expect nth(["a", "b", "c", "d", "e"], 2) == Ok("c")
expect nth(["a"], 2) == Err(OutOfBounds)
thread 86303100 panic: reached unreachable code
/opt/homebrew/Cellar/zig/0.15.2/lib/zig/std/debug.zig:559:14: 0x1082bf6af in assert (roc)
    if (!ok) unreachable; // assertion failure
             ^
.../roc/src/eval/interpreter.zig:7764:37: 0x10883a6ff in patternMatchesBind (roc)
                    std.debug.assert(list_rt_content == .structure);
                                    ^
.../roc/src/eval/interpreter.zig:7713:64: 0x108839ffb in patternMatchesBind (roc)
                    const matched = try self.patternMatchesBind(pat_ids[idx], elem_value, elem_vars[idx], roc_ops, out_binds, expr_idx);
                                                               ^
.../roc/src/eval/interpreter.zig:15486:57: 0x1086a140f in applyContinuation (roc)
                        if (!try self.patternMatchesBind(
                                                        ^
.../roc/src/eval/interpreter.zig:10723:67: 0x108521fab in evalWithExpectedType (roc)
                    const should_continue = self.applyContinuation(&work_stack, &value_stack, cont, roc_ops) catch |err| {
                                                                  ^
.../roc/src/eval/interpreter.zig:687:45: 0x108530ba7 in eval (roc)
        return try self.evalWithExpectedType(expr_idx, roc_ops, null);
                                            ^
.../roc/src/eval/test_runner.zig:203:49: 0x10853b387 in eval (roc)
        const result = try self.interpreter.eval(expr_idx, ops);
                                                ^
.../roc/src/eval/test_runner.zig:228:41: 0x1085399a7 in eval_all (roc)
                const result = self.eval(stmt.s_expect.body) catch |err| {
                                        ^
.../roc/src/cli/main.zig:4897:41: 0x10853f293 in rocTest (roc)
    const summary = test_runner.eval_all() catch |err| {
                                        ^
.../roc/src/cli/main.zig:762:45: 0x10859e433 in mainArgs (roc)
        .test_cmd => |test_args| try rocTest(&ctx, test_args),
                                            ^
.../roc/src/cli/main.zig:643:13: 0x10859ffdf in main (roc)
    mainArgs(&allocs, args) catch |err| {
            ^
/opt/homebrew/Cellar/zig/0.15.2/lib/zig/std/start.zig:627:37: 0x1085a062f in main (roc)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x19e736b97 in ??? (???)
???:?:?: 0x0 in ??? (???)
[1]    73447 abort      ./zig-out/bin/roc test file.roc

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions