[Feature Request] Add support for recursive `@parameter` closures
Open
Nobody has claimed this yet.
bug
mojo
mojo-repo
- Dominant language
- Mojo
- Stars
- 29.8k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Bug description
As title.
Steps to reproduce
fn fib(n: Int) -> Int:
@parameter
fn fib_tail(n: Int, a: Int, b: Int) -> Int:
if n < 1:
return 0
elif n == 1:
return b
return fib_tail(n - 1, b, a + b)
return fib_tail(n, 0, 1)
System information
Mojo 2024.8.2916 (1e9c68e6) on Docker, Intel Mac
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the recursive @parameter closure example in the reported Mojo 2024.8.2916 Docker environment and trace how the compiler handles fib_tail. Review the relevant compiler support for parameter closures; done means the example compiles and produces the expected Fibonacci result.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100