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
[BUG] using inout for decorator incorrectly causes weird compiler error #2152
Comments
Out of curiosity while you're here, why is the fn hello_decorator(borrowed func: fn() -> None) -> fn() escaping -> None:
fn inner1():
print("Hello, this is before function execution")
func()
print("This is after function execution")
return inner1
fn main():
@hello_decorator
fn function_to_be_used():
print("This is inside the function !!")
# calling the function
function_to_be_used() |
@arthurevans @scottamain fyi on comment just above, no docs currently on |
Minimal repro this also causes to parser crash: fn decorator(inout func: fn() -> None):
fn inner1():
func()
fn main():
pass |
I've added an issue to document closures for 24.3. https://github.com/modularml/modular/issues/36537 Currently these keywords only appear when you're declaring a type that's a closure. There are two signatures, AFAIK, Mojo doesn't support dynamic decorators like you're trying to define. Mojo's current decorators are hardcoded. (See https://docs.modular.com/mojo/roadmap#full-mlir-decorator-reflection) To verify this you can add a print statement to the body of |
Yes, I noticed the function ran but not the prints in the decorator (second comment) |
@Moosems Right. I was just pointing out that's because the function |
Are there any plans for that in the near/semi-near future? |
Bug description
MRE:
Error:
Steps to reproduce
Run code here (Mojo Playground)
System information
The text was updated successfully, but these errors were encountered: