feat: support function references as parameters (&fn type)#755
Merged
Conversation
Enable named functions to be passed as function-type arguments (e.g., `apply(&double, 21)` where `apply(f: &fn(i32) -> i32, ...)`). Changes: - Resolver: auto-dereference &fn(...) types when calling through function references (peel_refs in call resolution) - Closure lowering: convert FuncRef nodes to zero-capture Closures so named functions flow through the existing closure pipeline - Collapse &FuncRef to plain Closure (since &fn = fn for GC types) - TypeTable: add peel_refs() utility - Panic on FuncRef reaching WIR translation (should be lowered) https://claude.ai/code/session_01MoFzgmhV5N3axgvwj1WXLW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apply(&double, 21)whereapply(f: &fn(i32) -> i32, ...))&fn(...)types when calling through function references (peel_refsin call resolution)FuncRefnodes to zero-captureClosureso named functions flow through the existing closure pipelineFuncRefreaching WIR translation (previously silently emittedi32 const 0)Test plan
fn_ref_parameter.wadopasses at all optimization levels (O0, O1, O2, O3, Os)on-task-donepasses (1278 passed, 0 failed)https://claude.ai/code/session_01MoFzgmhV5N3axgvwj1WXLW