Skip to content

selfhost: add overload call bridge and registry collector - #767

Closed
godofecht wants to merge 8 commits into
mainfrom
selfhost/overload-call-bridge
Closed

godofecht wants to merge 8 commits into
mainfrom
selfhost/overload-call-bridge

Conversation

@godofecht

@godofecht godofecht commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Continues #677 after #722 without changing typecheck.flow yet.

Adds compiler/src/overload_call.flow, a context-neutral bridge that takes an AST call plus TcCtx-supplied identifier type-node ids, performs #722 argument classification, and invokes the native selector. FlowcOverloadCallScratch owns reusable rows/known/literal/identifier buffers so the call-check hot path performs no per-call allocation. flowc_overload_call_prepare clears identifier slots every call to prevent stale scope metadata from influencing later resolution. Scratch/classification failures remain FLOWC_OVERLOAD_SELECT_UNKNOWN so Stage-A cannot manufacture false no-match diagnostics from incomplete local information.

Adds compiler/src/overload_registry.flow, a local-program AST walker that registers plain and exported function declarations into FlowcOverloadTable by name/arity/decl id and can reset the table between bundle modules without reallocating it. Reset preserves a dead/uninitialized table error instead of hiding allocation failure.

Adds focused Flow tests covering zero-arg selection, ordinary literal selection, u32 literal widening, unknown multi-candidate calls, typed identifier selection, scratch clearing/capacity guards, same-name different-arity registration, exported function registration, and registry reset.

All branch commits carry [skip ci]; this work is intended for local qualification under the current 1.0.2 no-hosted-CI policy.

After this PR, the final #677 typecheck.flow splice is intentionally small: own/init/free/reset a FlowcOverloadTable and FlowcOverloadCallScratch; call flowc_overload_registry_collect once per module; map AST_IDENT call args with existing flowc_tc_lookup_val_type into scratch; call flowc_overload_resolve_call; diagnose only AMBIGUOUS and known NO_MATCH, while preserving existing intrinsic/import/extern handling and UNKNOWN fallback.

Related: #674 #677 #709 #713 #715 #717 #722 #725

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