Skip to content

Commit 4ea6038

Browse files
committed
fix(kompile): map linked NormalSym functions to monoItemFn(noBody)
Linked NormalSym functions (external crate functions present in SMIR but without a local body) had no generated monoItemFn equation, falling back to "** UNKNOWN FUNCTION **". This synthesizes monoItemFn(symbol(...), defId(...), noBody) for all such symbols, ensuring downstream call resolution can find them.
1 parent 2c84b7f commit 4ea6038

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

kmir/src/kmir/kompile.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,20 @@ def _functions(kmir: KMIR, smir_info: SMIRInfo) -> dict[int, KInner]:
529529
[KApply('symbol(_)_LIB_Symbol_String', [stringToken(sym['IntrinsicSym'])])],
530530
)
531531

532+
# Add linked normal symbols that have no local body in `items`.
533+
# They must still map to `monoItemFn(..., noBody)` instead of falling back to UNKNOWN FUNCTION.
534+
for ty, sym in smir_info.function_symbols.items():
535+
normal_sym = sym.get('NormalSym')
536+
if isinstance(normal_sym, str) and ty not in functions:
537+
functions[ty] = KApply(
538+
'MonoItemKind::MonoItemFn',
539+
(
540+
KApply('symbol(_)_LIB_Symbol_String', (stringToken(normal_sym),)),
541+
KApply('defId(_)_BODY_DefId_Int', (intToken(ty),)),
542+
KApply('noBody_BODY_MaybeBody', ()),
543+
),
544+
)
545+
532546
return functions
533547

534548

0 commit comments

Comments
 (0)