Stream: bugs

Topic: Panic in new compiler


view this post on Zulip Jamie (Dec 09 2025 at 17:03):

I have a roc file called main.roc, and when I try to run it with roc run ./main.roc (compiled from this commit), I get the error:

thread 27610 panic: index out of bounds: index 2863311530, len 1611
/home/jg/roc/src/types/instantiate.zig:341:60: 0x54b53c7 in instantiateTagUnion (mod.zig)
                const arg_var = self.store.vars.items.items[args_start + i];
                                                           ^
/home/jg/roc/src/types/instantiate.zig:227:90: 0x53cea36 in instantiateFlatType (mod.zig)
            .tag_union => |tag_union| FlatType{ .tag_union = try self.instantiateTagUnion(tag_union) },
                                                                                         ^
/home/jg/roc/src/types/instantiate.zig:183:69: 0x52839d8 in instantiateContent (mod.zig)
                const fresh_flat_type = try self.instantiateFlatType(flat_type);
                                                                    ^
/home/jg/roc/src/types/instantiate.zig:152:66: 0x509881f in instantiateVar (mod.zig)
                const fresh_content = try self.instantiateContent(resolved.desc.content);
                                                                 ^
/home/jg/roc/src/types/instantiate.zig:357:43: 0x54b5f0d in instantiateTagUnion (mod.zig)
            .ext = try self.instantiateVar(tag_union.ext),
                                          ^
/home/jg/roc/src/types/instantiate.zig:227:90: 0x53cea36 in instantiateFlatType (mod.zig)
            .tag_union => |tag_union| FlatType{ .tag_union = try self.instantiateTagUnion(tag_union) },
                                                                                         ^
/home/jg/roc/src/types/instantiate.zig:183:69: 0x52839d8 in instantiateContent (mod.zig)
                const fresh_flat_type = try self.instantiateFlatType(flat_type);
                                                                    ^
/home/jg/roc/src/types/instantiate.zig:152:66: 0x509881f in instantiateVar (mod.zig)
                const fresh_content = try self.instantiateContent(resolved.desc.content);
                                                                 ^
/home/jg/roc/src/types/instantiate.zig:212:58: 0x53cda4a in instantiateAlias (mod.zig)
        const fresh_backing_var = try self.instantiateVar(backing_var);
                                                         ^
/home/jg/roc/src/types/instantiate.zig:179:49: 0x52838a8 in instantiateContent (mod.zig)
                return try self.instantiateAlias(alias);
                                                ^
/home/jg/roc/src/types/instantiate.zig:152:66: 0x509881f in instantiateVar (mod.zig)
                const fresh_content = try self.instantiateContent(resolved.desc.content);
                                                                 ^
/home/jg/roc/src/types/instantiate.zig:342:58: 0x54b5419 in instantiateTagUnion (mod.zig)
                const fresh_arg = try self.instantiateVar(arg_var);
                                                         ^
/home/jg/roc/src/types/instantiate.zig:227:90: 0x53cea36 in instantiateFlatType (mod.zig)
            .tag_union => |tag_union| FlatType{ .tag_union = try self.instantiateTagUnion(tag_union) },
                                                                                         ^
/home/jg/roc/src/types/instantiate.zig:183:69: 0x52839d8 in instantiateContent (mod.zig)
                const fresh_flat_type = try self.instantiateFlatType(flat_type);
                                                                    ^
/home/jg/roc/src/types/instantiate.zig:152:66: 0x509881f in instantiateVar (mod.zig)
                const fresh_content = try self.instantiateContent(resolved.desc.content);
                                                                 ^
/home/jg/roc/src/types/instantiate.zig:234:58: 0x54b20ad in instantiateNominalType (mod.zig)
        const fresh_backing_var = try self.instantiateVar(backing_var);
                                                         ^
/home/jg/roc/src/types/instantiate.zig:220:97: 0x53ce0cf in instantiateFlatType (mod.zig)
            .nominal_type => |nominal| FlatType{ .nominal_type = try self.instantiateNominalType(nominal) },
                                                                                                ^
/home/jg/roc/src/types/instantiate.zig:183:69: 0x52839d8 in instantiateContent (mod.zig)
                const fresh_flat_type = try self.instantiateFlatType(flat_type);
                                                                    ^
/home/jg/roc/src/types/instantiate.zig:152:66: 0x509881f in instantiateVar (mod.zig)
                const fresh_content = try self.instantiateContent(resolved.desc.content);
                                                                 ^
/home/jg/roc/src/check/Check.zig:545:61: 0x4da5790 in instantiateVarHelp (mod.zig)
    const instantiated_var = try instantiator.instantiateVar(var_to_instantiate);
                                                            ^
/home/jg/roc/src/check/Check.zig:490:35: 0x4b71fb8 in instantiateVar (mod.zig)
    return self.instantiateVarHelp(var_to_instantiate, &instantiate_ctx, env, region_behavior);
                                  ^
/home/jg/roc/src/check/Check.zig:3093:61: 0x4b245fb in checkExpr (mod.zig)
                const instantiated = try self.instantiateVar(pat_var, env, .use_last_var);
                                                            ^
/home/jg/roc/src/check/Check.zig:2829:45: 0x4b2103e in checkExpr (mod.zig)
                does_fx = try self.checkExpr(single_elem_expr_idx, env, .no_expectation) or does_fx;
                                            ^
/home/jg/roc/src/check/Check.zig:3351:53: 0x4b27fdd in checkExpr (mod.zig)
                        does_fx = try self.checkExpr(call_arg_idx, env, .no_expectation) or does_fx;
                                                    ^
/home/jg/roc/src/check/Check.zig:4262:37: 0x4d86564 in checkMatchExpr (mod.zig)
    var does_fx = try self.checkExpr(match.cond, env, .no_expectation);
                                    ^
/home/jg/roc/src/check/Check.zig:3547:46: 0x4b2a6b0 in checkExpr (mod.zig)
            does_fx = try self.checkMatchExpr(expr_idx, env, match) or does_fx;
                                             ^
/home/jg/roc/src/check/Check.zig:3843:49: 0x4d7ea0b in checkBlockStatements (mod.zig)
                    does_fx = try self.checkExpr(decl_stmt.expr, env, expectation) or does_fx;
                                                ^
/home/jg/roc/src/check/Check.zig:3137:62: 0x4b24f98 in checkExpr (mod.zig)
            const stmt_result = try self.checkBlockStatements(statements, env, expr_region);
                                                             ^
/home/jg/roc/src/check/Check.zig:4317:37: 0x4d87227 in checkMatchExpr (mod.zig)
        does_fx = try self.checkExpr(branch.value, env, .no_expectation) or does_fx;
                                    ^
/home/jg/roc/src/check/Check.zig:3547:46: 0x4b2a6b0 in checkExpr (mod.zig)
            does_fx = try self.checkMatchExpr(expr_idx, env, match) or does_fx;
                                             ^
/home/jg/roc/src/check/Check.zig:3141:41: 0x4b250e7 in checkExpr (mod.zig)
            does_fx = try self.checkExpr(block.final_expr, env, expected) or does_fx;
                                        ^
/home/jg/roc/src/check/Check.zig:3299:49: 0x4b272d2 in checkExpr (mod.zig)
                    does_fx = try self.checkExpr(lambda.body, env, .no_expectation) or does_fx;
                                                ^
/home/jg/roc/src/check/Check.zig:3331:41: 0x4b27b9e in checkExpr (mod.zig)
            does_fx = try self.checkExpr(closure.lambda_idx, env, expected) or does_fx;
                                        ^
/home/jg/roc/src/check/Check.zig:1247:35: 0x4b19f77 in checkDef (mod.zig)
            _ = try self.checkExpr(def.expr, env, .no_expectation);
                                  ^
/home/jg/roc/src/check/Check.zig:1026:26: 0x48ddc51 in checkFile (mod.zig)
        try self.checkDef(def_idx, &env);
                         ^
/home/jg/roc/src/cli/main.zig:1862:30: 0x458872d in setupSharedMemoryWithModuleEnv (main.zig)
    try app_checker.checkFile();
                             ^
/home/jg/roc/src/cli/main.zig:1109:54: 0x4595f9f in rocRun (main.zig)
    const shm_result = setupSharedMemoryWithModuleEnv(allocs, args.path, args.allow_errors) catch |err| {
                                                     ^
/home/jg/roc/src/cli/main.zig:680:23: 0x4836a05 in mainArgs (main.zig)
            try rocRun(allocs, run_args);
                      ^
/home/jg/roc/src/cli/main.zig:619:13: 0x4838fb8 in main (main.zig)
    mainArgs(&allocs, args) catch {
            ^
/home/jg/binary-repository/downloadedSources/zig/lib/std/start.zig:627:37: 0x4839571 in main (std.zig)
            const result = root.main() catch |err| {
                                    ^
/home/jg/binary-repository/downloadedSources/zig/lib/libc/musl/src/env/__libc_start_main.c:95:7: 0x9437d9d in libc_start_main_stage2 (/home/jg/binary-repository/downloadedSources/zig/lib/libc/musl/src/env/__libc_start_main.c)
 exit(main(argc, argv, envp));
      ^
???:?:?: 0x9433349 in ??? (???)
Unwind error at address `exe:0x9433349` (error.MissingFDE), trace may be incomplete

Aborted                    (core dumped) ~/roc/zig-out/bin/roc run ./main2.roc

view this post on Zulip Matthieu Pizenberg (Dec 09 2025 at 17:06):

I don’t think there is a run subcommand. It would be roc main.roc directly.

view this post on Zulip Jamie (Dec 09 2025 at 17:07):

roc run seems to work the same as just roc

view this post on Zulip Matthieu Pizenberg (Dec 09 2025 at 17:09):

I see you are calling File.read_utf8 but I don’t think the temporary platform made for AoC by @Luke Boswell has file IO yet.

view this post on Zulip Anton (Dec 09 2025 at 17:22):

Yeah, no File support yet

view this post on Zulip Jamie (Dec 09 2025 at 17:31):

Yeah, my program is really bad right now, and it probably has lots of bugs in it. One of the issues is using unimplemented things like file reading/writing, Inspect.to_str, and Num.to_str. But the new compiler should still be able to always either run a program or give a list of errors that the program has.

view this post on Zulip Jamie (Dec 09 2025 at 17:32):

And this bug stops that from working

view this post on Zulip Anton (Dec 09 2025 at 17:54):

Agreed :)
Can you make a github issue?

view this post on Zulip Jamie (Dec 09 2025 at 18:34):

Here is the issue I've created https://github.com/roc-lang/roc/issues/8599


Last updated: Dec 21 2025 at 12:15 UTC