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

[BUG] Can't explicitly type a variable set to __init__ of some struct #3899

Closed
soraros opened this issue Dec 19, 2024 · 1 comment
Closed
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@soraros
Copy link
Contributor

soraros commented Dec 19, 2024

Bug description

As title. CC. @lattner.

It's extra bad since this example is taken from the change log.

Steps to reproduce

struct S:
  fn __init__(out self):
    pass

fn main():
  # error: function cannot have both an 'out' argument and an explicit result type; remove the '-> None' to fix it
  var f1: fn (out x: S) -> None = S.__init__

  # error: cannot implicitly convert 'fn(out self: S) -> None' value to 'fn() -> S' in 'var' initialize
  var f2: fn (out x: S) = S.__init__

  # this works
  var f3 = S.__init__

The first spelling does work for ordinary function with out argument though:

fn f(out self: Int):
  self = 0

fn main():
  var f1: fn (out x: Int) = f

System information

Mojo 25.1.0.dev2024121705 (67a9f701) on Docker, Intel Mac.
@soraros soraros added bug Something isn't working mojo-repo Tag all issues with this label labels Dec 19, 2024
@soraros
Copy link
Contributor Author

soraros commented Dec 25, 2024

Does not reproduce any more on mojo 25.1.0.dev2024122405 (76eafd8b).

@soraros soraros closed this as completed Dec 25, 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

1 participant