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

Cannot initialize types that have static values. #1605

Open
lucteo opened this issue Oct 22, 2024 · 2 comments
Open

Cannot initialize types that have static values. #1605

lucteo opened this issue Oct 22, 2024 · 2 comments

Comments

@lucteo
Copy link
Contributor

lucteo commented Oct 22, 2024

See the following code:

type MyEnum {
  memberwise init

  internal let value: Int

  public static let static_value: MyEnum = construct_some_value()

  public static fun construct_some_value() -> MyEnum {
    return .new(value: 0)
  }
}

Compiling this yields:

Bug.hylo:9.12-16: error: incompatible labels: found '(value:)', expected '(value:static_value:)'
    return .new(value: 0)
           ~~~~
make: *** [bug] Error 1

It seems that the initializer incorrectly also requires the static value to be constructed.

@lucteo
Copy link
Contributor Author

lucteo commented Oct 22, 2024

Moving the static variable in an extension, solves the compilation issue.

@kyouko-taiga
Copy link
Contributor

Nice detective work. It means the bug is caused by the logic that is enumerating the fields that must be initialized before self can be considered whole.

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

No branches or pull requests

2 participants