-
That is cool, but is expected behaviour?
|
Beta Was this translation helpful? Give feedback.
Answered by
lattner
Sep 13, 2023
Replies: 2 comments 3 replies
-
I think it is a bug in the type system. Hard to believe that it is an intentional feature, as it would make the type system unreliable. |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is intentional. Putting struct my_struct:
fn __init__(inout self, x: Int):
self.x = x Which enables implicit conversion from |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep that's what happens. I think it is super debatable whether that is a good thing though :-). Mojo doesn't have the notion of "explicit" constructors - I think we should require
custom = my_struct(x)
but we don't have a way to express that yet.