-
-
Notifications
You must be signed in to change notification settings - Fork 820
Suggest wrapping value in Ok
or Error
if it makes sense
#3663
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
Suggest wrapping value in Ok
or Error
if it makes sense
#3663
Conversation
Looks like you forgot to accept the snapshot again :) |
Ah yeah this time it's intentional, I'm not really satisfied with how the error looks for case expressions 😆 |
4069083
to
9560d6c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Left 1 comment inline.
Could we have some tests for in use
and returned from a function annotated as being result? Those will be the most common I think.
Hey! 💜 I tried your
The last one means that your new hint doesn't work for these cases for example: pub fn wibble() -> Result(List(String), Nil) {
[] // List(a) `same_as` List(String)
}
pub fn wobble() -> Result(List(b), Nil) {
[] // List(a) `same_as` List(b)
} I feel like it would be more useful if unbound type variables where allowed to match any type on the right-hand side; Something like ~ yoshi |
Hello! Are you still working on this one? Thanks |
Oh my I hadn't noticed the conflicts, once those are solved I think this is ready for review! |
bcc7a89
to
134eb59
Compare
This is ready now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful, thank you! Left a few small notes
3ecd9c9
to
d280253
Compare
This should be ready now! |
ffbca4f
to
dfa7d2e
Compare
CHANGELOG.md
Outdated
5 │ [first, ..rest] -> first | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
│ │ | ||
│ Did you mean to wrap this in an `Ok`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changelog entry needs updating I think? It no longer makes this suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thank you!
Previously it would consider two identical named types (with different variants) to have a different type. But that is not the case: `True` and `False` have the same type, even though they have a different inferred variant.
b07330c
to
e99aa17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!!
As suggested by @GearsDatapacks the compiler can now suggest to wrap a value into an
Ok
/Error
if it would make the types line up:This is a WIP because I still have to figure out how to pretty print this information in pattern matching branches, right now it looks quite bad 😁