Skip to content

feat: support function references as parameters (&fn type)#755

Merged
gfx merged 2 commits intomainfrom
claude/implement-fn-ref-parameter-fLpJR
Apr 2, 2026
Merged

feat: support function references as parameters (&fn type)#755
gfx merged 2 commits intomainfrom
claude/implement-fn-ref-parameter-fLpJR

Conversation

@gfx
Copy link
Copy Markdown
Member

@gfx gfx commented Apr 2, 2026

Summary

  • Enable named functions to be passed as function-type arguments (e.g., apply(&double, 21) where apply(f: &fn(i32) -> i32, ...))
  • Resolver: auto-dereference &fn(...) types when calling through function references (peel_refs in call resolution)
  • Closure lowering: convert FuncRef nodes to zero-capture Closure so named functions flow through the existing closure pipeline
  • Panic on FuncRef reaching WIR translation (previously silently emitted i32 const 0)

Test plan

  • fn_ref_parameter.wado passes at all optimization levels (O0, O1, O2, O3, Os)
  • All 4495 E2E tests pass
  • on-task-done passes (1278 passed, 0 failed)

https://claude.ai/code/session_01MoFzgmhV5N3axgvwj1WXLW

claude added 2 commits April 2, 2026 10:39
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
@gfx gfx enabled auto-merge April 2, 2026 10:54
@gfx gfx merged commit e6db6a1 into main Apr 2, 2026
10 checks passed
@gfx gfx deleted the claude/implement-fn-ref-parameter-fLpJR branch April 2, 2026 11:00
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.

2 participants