Skip to content

ice: identifier that passed typeck should exist in the CgScope #552

Description

@thetayloredman

Before we begin...

  • I have updated the Zirco toolchain to the latest version
  • I have searched the issue tracker for duplicates

What was the ICE diagnostic?

error: internal compiler error encountered: thread panicked
note: this is not your fault! this is ALWAYS a compiler bug.
note: compiler bugs threaten the Zirco ecosystem -- we would appreciate a bug report:
note: bug reporting link: https://github.com/zirco-lang/zrc/issues/new?template=ice.yml

note: zrc version 0.1.0 (aa54c5b2b125d25e92606c243a030e71d6f7c5c8, not tainted) built for aarch64-apple-darwin on 2025-11-30T20:23:28-08:00 (release mode)
note: rustc 1.92.0-nightly (695857bc3 2025-10-21) (nightly-aarch64-apple-darwin on macos-aarch64)
note: cargo 1.92.0-nightly (367fd9f21 2025-10-15)

note: command line arguments: zrc ../repr.zr


thread 'main' (1789357) panicked at compiler/zrc_codegen/src/expr/place.rs:55:18:
identifier that passed typeck should exist in the CgScope
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: zrc_codegen::expr::place::cg_place
   4: zrc_codegen::expr::cg_expr
   5: zrc_codegen::stmt::cg_block
   6: zrc_codegen::program::cg_program
   7: zrc_codegen::program::cg_program_to_string
   8: zrc::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: end internal compiler error. compilation failed.

What were you doing when the panic occured?

zrc ../repr.zr - discovered when working on AOC

Provide an example of code that causes the panic.

fn main() -> i32 {
    return f();
}

fn f() -> i32 {
    return 1;
}

Other Context

The code generator is happy when you AOT declare the fn f() -> i32; and then redefine it later. Unlike typeck, it is however not happy if it is not declared ahead of time.

Metadata

Metadata

Labels

A-codegenRelating to the code generatorE-good-first-issueCall for participation: Easy issue. Good for newcomers.P-mediumThe bug is noticeable but does not significantly affect most use casesS-workaroundA workaround is known.T-ICEInternal Compiler Errors (panics or crashes)

Type

No type

Projects

Status
Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions