Skip to content

feat(ownership): preserve function parameter capabilities through MIR - #385

Draft
dporkka wants to merge 6 commits into
fix/consume-runtime-movefrom
feat/ownership-param-metadata
Draft

dporkka wants to merge 6 commits into
fix/consume-runtime-movefrom
feat/ownership-param-metadata

Conversation

@dporkka

@dporkka dporkka commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #384.

Preserves source-level function parameter capabilities through HIR into MIR's existing Local.cap metadata.

  • HIR FunctionDef now carries a capability vector aligned with params
  • explicit params and using params retain their declared capability
  • compiler-generated typeclass dictionary params are marked ref
  • MIR FunctionBuilder gains add_param_with_cap
  • HIR → MIR lowering stores the capability on each parameter local
  • lowering rejects misaligned parameter/capability metadata instead of silently truncating
  • adds focused HIR and MIR regression tests
  • updates direct HIR test fixtures

Why

Nulang's capability checker already models linear/unique ownership, but HIR previously erased parameter capabilities. The Drop planner therefore could not distinguish an ownership-transfer parameter from a borrowed/shared parameter.

This patch changes no calling convention and no runtime behavior. It only preserves metadata required for a later sound sink/ownership-flow optimization.

Stack

Depends on #384 (consume runtime move-out).

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 18, 2026

Copy link
Copy Markdown

Deploying nulang-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: ab592f1
Status: ✅  Deploy successful!
Preview URL: https://de71cd94.nulang-docs.pages.dev
Branch Preview URL: https://fix-ownership-consumption-fl.nulang-docs.pages.dev

View logs

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.

1 participant