Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add support for recursive @parameter closures #3432

Open
soraros opened this issue Aug 29, 2024 · 2 comments
Open

[Feature Request] Add support for recursive @parameter closures #3432

soraros opened this issue Aug 29, 2024 · 2 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@soraros
Copy link
Contributor

soraros commented Aug 29, 2024

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
@soraros soraros added bug Something isn't working mojo-repo Tag all issues with this label labels Aug 29, 2024
@bpr
Copy link

bpr commented Sep 1, 2024

### Nested functions cannot be recursive

@soraros
Copy link
Contributor Author

soraros commented Sep 1, 2024

@bpr Ah, right. Let me make this a feature request for @parameter closures.

Actually, I'm not so sure now. I think the roadmap was written before the new closure model, so it was taking about @parameter fib_tail not fib_tail which was in my original bug report. At least the compiler should give proper error message if @parameter's missing.

@soraros soraros changed the title [BUG] Simple recursive program fails to compile [Feature Request] Add support for recursive @parameter closures Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants