Skip to content

c_import: a method c_import generates for a C type yields to a written method of the same name (§16.2a), so MIR no longer lowers an unchecked body (#2403) - #2651

Merged
ehartford merged 1 commit into
fix-2412from
fix-2403
Oct 25, 2026
Merged

ehartford merged 1 commit into
fix-2412from
fix-2403

Conversation

@ehartford

@ehartford ehartford commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: Zcu.expand_c_imports_frontend (src/compiler/Frontend.w) re-added
every ordered declaration, c_import's generated methods included, after the
tier rebuild had already run (process_imports, then expand_c_imports). A
generated xdoc.root beside a written impl xdoc: fn root() was registered
twice; Sema checked the written one and MIR lowered the generated body,
whose call of xdoc_root had no resolution: "MirLower ICE: call of
xdoc_root has callee kind 0". §16.2a: "User-written impl methods always
take priority over auto-generated ones."

The final re-add now collects the written methods' qualified names and skips
a generated method with the same name, keeping the parallel path/file/ci
lists in step.

Test: test/behavior/behav_2403_c_sugar_yields_to_written_method.{w,h}
(expect 7). The installed compiler stops with the MirLower ICE.

Closes #2403

…n method of the same name (§16.2a), so MIR no longer lowers an unchecked body (#2403)

Root cause: Zcu.expand_c_imports_frontend (src/compiler/Frontend.w) re-added
every ordered declaration, c_import's generated methods included, after the
tier rebuild had already run (process_imports, then expand_c_imports). A
generated `xdoc.root` beside a written `impl xdoc: fn root()` was registered
twice; Sema checked the written one and MIR lowered the generated body,
whose call of `xdoc_root` had no resolution: "MirLower ICE: call of
`xdoc_root` has callee kind 0". §16.2a: "User-written `impl` methods always
take priority over auto-generated ones."

The final re-add now collects the written methods' qualified names and skips
a generated method with the same name, keeping the parallel path/file/ci
lists in step.

Test: test/behavior/behav_2403_c_sugar_yields_to_written_method.{w,h}
(expect 7). The installed compiler stops with the MirLower ICE.
@ehartford
ehartford added this pull request to stack #2658 October 25, 2026 21:47
@ehartford ehartford changed the title fix 2403 c_import: a method c_import generates for a C type yields to a written method of the same name (§16.2a), so MIR no longer lowers an unchecked body (#2403) Oct 25, 2026
@ehartford
ehartford marked this pull request as ready for review October 25, 2026 21:59
@ehartford
ehartford merged commit b995a30 into main Oct 25, 2026
@ehartford
ehartford deleted the fix-2403 branch October 25, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A user method colliding with §16.2a c_import sugar is lowered unchecked: MirLower ICE 'callee kind 0', no diagnostic

1 participant